UtilityPack.Logger 1.1.8

dotnet add package UtilityPack.Logger --version 1.1.8
NuGet\Install-Package UtilityPack.Logger -Version 1.1.8
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UtilityPack.Logger" Version="1.1.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UtilityPack.Logger --version 1.1.8
#r "nuget: UtilityPack.Logger, 1.1.8"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install UtilityPack.Logger as a Cake Addin
#addin nuget:?package=UtilityPack.Logger&version=1.1.8

// Install UtilityPack.Logger as a Cake Tool
#tool nuget:?package=UtilityPack.Logger&version=1.1.8

Logger

Logger provides a single static class, with several static methods that take care of performing rapid writing of files to disk in predefined places.

Enum LogLocation

  • ROOT
    C:/
  • CUSTOM
    Custom Path
  • EXEDIR
    ../exe_directory/
  • PROGDATA
    C:/ProgramData/
  • APPDATAROAM
    ../AppData/Roaming
  • APPDATALOCA
    ../AppData/Local

Class Logger

Property

  • IsLogActive : bool
    Only if set to 'true' the Logger methods will actually save files to disk. (Default true)

  • IsCatchErrorActive : bool
    If true, when an error occur it will be thrown, otherwhise the functions will silently return false. (Default false)

  • BasePath : string
    Root directory where to save the logs. (Default same directory as the exe)

  • SubPath : string
    Additional sub directories where save the logs, added at the end of BasePath. (Default "")

  • MaxFileSize : long
    Max size of a log file, if the file exceed this value and "IsSizeLimitActive" is set to true, the file will be cleared. (Default value = 5 MB = 1048576 Byte)

  • IsSizeLimitActive : boolean
    If set to true, when a file exceed the "MaxFileSize" it will be cleared at the next log saving.

  • LogAppendSpace : int
    Number of new line beetween a content append and the next one. (Default 3)

Method

  • SetLocation(LogLocation location, string? customDir)
    Set the log save location

  • SetSubLocation(string subLocation)
    Set the log folder sub location

  • SetMaxFileSize(long maxByteSize)
    Activate the size limit control and set the "MaxFileSize" value to as pecific number

  • SaveText(string text, string? name , bool? append)
    Save some text to file in the log directory as a file .txt

  • SaveJson(string text, string? name , bool? append)
    Save some json text to file in the log directory as a file .json

  • SaveJson(object text, string? name , bool? append)
    Save a json object to file in the log directory as a file .json

  • SaveJsonList< T >(List< T > list, string? name , bool? append)
    Save a list of json objects to file in the log directory as a file .json

  • ClearLogFolder(string? chosenPath)
    Delete every file inside the log folder, if another folder BasePath is specified, clear it instead

Example

class jsonObj
{
	public string Name;
	public int Age;
}

static void Main()
{
	// Set the main log folder location
	Logger.SetLocation(LogLocation.APPDATALOCA, "ProgramLogs");

	// Save a simple text message on a report.txt file located in the log folder
	Logger.SaveText("Report message", "report");

	// Create and append a json like object to a report_data.json file located in the log folder
	jsonObj json = new()
	{
		Name = "Burt",
		Age  = 20
	};

	Logger.SaveJson(json, "report_data", true);
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 is compatible.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.8 425 6/30/2022
1.1.7 394 5/31/2022
1.1.6 389 5/16/2022
1.1.5 387 5/16/2022
1.1.4 399 5/16/2022
1.1.3 397 3/29/2022
1.1.2 409 2/17/2022
1.1.1 400 2/17/2022
1.1.0 418 2/4/2022
1.0.3 403 2/4/2022
1.0.2.2 406 2/4/2022
1.0.2.1 396 2/4/2022
1.0.2 236 12/30/2021
1.0.1 240 12/29/2021
1.0.0 264 11/17/2021