SimpleRollingLogger 1.0.1

dotnet add package SimpleRollingLogger --version 1.0.1                
NuGet\Install-Package SimpleRollingLogger -Version 1.0.1                
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="SimpleRollingLogger" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleRollingLogger --version 1.0.1                
#r "nuget: SimpleRollingLogger, 1.0.1"                
#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 SimpleRollingLogger as a Cake Addin
#addin nuget:?package=SimpleRollingLogger&version=1.0.1

// Install SimpleRollingLogger as a Cake Tool
#tool nuget:?package=SimpleRollingLogger&version=1.0.1                

SimpleRollingLogger

A simple lightweight logger with rolling log files.

Breakdown

Logger implements ILogger and has 3 properties...

/// <summary>Gets or sets the log file.</summary>
public string LogFile { get; set; }

/// <summary>Gets or sets the file size to roll the log file at. If less than 0 then the log file will not be rolled. Default is 102400 (100KB).</summary>
public long LogRollSize { get; set; } = 102400; // 100KB default

/// <summary>Gets or sets the log level for the logger. Default is Trace.</summary>
public LogLevel LogLevel { get; set; } = LogLevel.Trace;

It has these methods...

public void Debug(string message)
protected void EnsureLogFile()
public void Error(string message)
public void Fatal(string message)
public void Info(string message)
public virtual bool RollLogFile()
public void Trace(string message)
public void Warning(string message)
protected virtual void WriteToLogFile(LogLevel level, string message)

It is very it to use. Just set the absolute path (including filename) to the LogFile property call the appropriate log method desired. Change the LogRollsize and LogLevel as desired.

Extension

RollLogFile is a part of the interface and marked virtual on the Logger so that you can override its behavior if you so desire. You do not have to call RollLogFile yourself in code. The API will call it when writing to the log file.

There is another method call, WriteToLogFile that is protected virtual so that if you extend the type so can also modify the actual file writing routine. Debug, Error, Fatal, Info, Trace and Warning all just call that method to actually write the data to the file. If overridding the WriteToLogFile method be sure to call EnsureLogFile prior to writing to the file. This is the APIs defense to no log file being set on the LogFile property.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.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.0.1 277 10/15/2023
1.0.0 155 10/15/2023