Duke.LogWriter
2.0.2
dotnet add package Duke.LogWriter --version 2.0.2
NuGet\Install-Package Duke.LogWriter -Version 2.0.2
<PackageReference Include="Duke.LogWriter" Version="2.0.2" />
paket add Duke.LogWriter --version 2.0.2
#r "nuget: Duke.LogWriter, 2.0.2"
// Install Duke.LogWriter as a Cake Addin #addin nuget:?package=Duke.LogWriter&version=2.0.2 // Install Duke.LogWriter as a Cake Tool #tool nuget:?package=Duke.LogWriter&version=2.0.2
About Duke.LogWriter
That small library is designed for creating log files and is usually used in command-line applications. By default, do not require any settings.
Installation
A simple way is to install it from the Nuget package library and it is ready to use. No additional settings are required.
dotnet add package Duke.LogWriter
Usage
using Duke.LogWriter;
LogWriter.Instance.WriteLog("Hello world", true);
That code will create in your application work directory a new subfolder with the name logs
and put the file in the format DukeLogWriter_yyyy_MM_dd.txt
. The log will look like
[05:57:01] Hello world
Write Header
LogWriter.Instance.WriteHeader("Application start", true);
That code will print header text with formatting.
[06:27:45] ================================================================================
[06:27:45] =============================== Application start ==============================
[06:27:45] ================================================================================
File Mask
The File mask default value is DukeLogWriter_{date}.txt
. You can change that mask.
LogWriter.Instance.FileMask = "TestLog_{date}.txt";
After that, all files will be in the format TestLog_yyyy_MM_dd.txt
Line Mask
The Line mask by default contains a time stamp + log string [{time}] {log}
. We can change it and remove the time value.
LogWriter.Instance.LineMask = "{log}";
LogWriter.Instance.WriteLog("Hello world", true);
As a result, there will not be a time stamp on the log line.
Log Folder
The logger by default creates a subfolder with the name logs
. You can change the name of the folder or set an empty string (will be used current application folder).
LogWriter.Instance.LogFolder = "BuildLogs";
Show In Console
By default, the logger does not print anything to the output console. It can be changed in two ways. Set the value to true
LogWriter.Instance.WriteLog("Hello world", true);
or by changing the default value.
LogWriter.Instance.ShowInConsoleDefault = true;
LogWriter.Instance.WriteLog("Hello world");
Product | Versions 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. |
-
net6.0
- System.Configuration.ConfigurationManager (>= 6.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.