Chase.SerilogExtension
0.0.1
dotnet add package Chase.SerilogExtension --version 0.0.1
NuGet\Install-Package Chase.SerilogExtension -Version 0.0.1
<PackageReference Include="Chase.SerilogExtension" Version="0.0.1" />
paket add Chase.SerilogExtension --version 0.0.1
#r "nuget: Chase.SerilogExtension, 0.0.1"
// 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 | Versions 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. |
-
net8.0
- Serilog.Sinks.File (>= 5.0.0)
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 | 118 | 5/18/2024 |
Initial Release