Chase.SerilogExtension 0.0.1

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

// Install Chase.SerilogExtension as a Cake Tool
#tool nuget:?package=Chase.SerilogExtension&version=0.0.1                

Chase Serilog Extension

This extension adds a EnhancedWriteToFile option to the Serilog logger to allow for additional options when logging to a file like automatically archiving old logs.

Usage

To use this extension, add the following using statement to your file:

using Chase.SerilogExtension;

Then, when initializing your logger, use the EnhancedWriteToFile method to specify the file path and options:

EnhancedWriteToFile

.EnhancedWriteToFile(
    directory: "logs", // The directory to write the log files to
    archiveOldLogs: true, // Whether or not to archive old logs
    flushToDiskInterval: TimeSpan.FromSeconds(30), // The interval to flush logs to disk, this will also set buffered to true
    maxLogSize: 10485760) // This will automatically archive the log file if it exceeds 10MB

AutoCloseAndFlush

This extension also adds an AutoCloseAndFlush method to the logger configuration that will automatically close and flush the logger when the application exits. This is useful for console applications that may not have a clean exit.

.AutoCloseAndFlush()

Example

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Verbose()
    .EnhancedWriteToFile(
        directory: "logs", // The directory to write the log files to
        archiveOldLogs: true, // Whether or not to archive old logs
        flushToDiskInterval: TimeSpan.FromSeconds(30), // The interval to flush logs to disk, this will also set buffered to true
        maxLogSize: 10485760) // This will automatically archive the log file if it exceeds 10MB

    .AutoCloseAndFlush() // This will automatically close and flush the logger when the application exits
    .CreateLogger();
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.

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
0.0.1 117 5/18/2024

Initial Release