DotLogs 1.0.6
dotnet add package DotLogs --version 1.0.6
NuGet\Install-Package DotLogs -Version 1.0.6
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="DotLogs" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotLogs" Version="1.0.6" />
<PackageReference Include="DotLogs" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotLogs --version 1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DotLogs, 1.0.6"
#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.
#:package DotLogs@1.0.6
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotLogs&version=1.0.6
#tool nuget:?package=DotLogs&version=1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DotLogs (core library)
Lightweight logging service built on Serilog with hot-reloadable configuration.
Install
dotnet add package DotLogs
Quick start
using DotLogs;
using var logs = new DotLogsService();
logs.LogInformation("Hello from DotLogs");
// Change level at runtime
logs.SetLevel("Debug");
logs.LogDebug("Debug now visible");
// React to config file changes
logs.ConfigurationUpdated += () => Console.WriteLine("Logs configuration reloaded");
First run creates a logs/ directory and a logs.config file that is watched automatically.
Configuration (logs/logs.config)
DotLogsService persists and watches settings in logs/logs.config.
Fields:
LogToConsole(bool, default true)LogToFile(bool, default true)LogLevel(string: Verbose/Trace, Debug, Information, Warning, Error, Fatal)Period(int retained files for rolling, default 30)RollingInterval(enum numeric, default Day)LogFileName(string, defaultlog.txt)LogFormat(Serilog output template)
Example:
{
"LogToConsole": true,
"LogToFile": true,
"LogLevel": "Information",
"Period": 30,
"RollingInterval": 3,
"LogFileName": "log.txt",
"LogFormat": "[{Timestamp:yyyy-MM-dd HH:mm:ss}] [{Level:u3}] [{Caller}] [{file}:{line}] {Message:lj}\n"
}
Edits are picked up live; no restart needed.
API
Logging methods:
LogTrace(message),LogDebug(message),LogInformation(message),LogWarning(message),LogError(message),LogFatal(message)
Log retrieval:
GetLogs(int nbDays)— get logs from past N daysGetLogs(DateTime? from)— get logs from specific date/timeGetLogs(DateTime from, LogEventLevel minLevel)— get logs from date with minimum levelGetLogs(int nbDays, LogEventLevel minLevel)— get logs from past N days with minimum levelGetLogs(LogEventLevel minLevel)— get logs from last 24h with minimum level
Configuration:
SetConfiguration(LogServiceConfiguration),GetConfiguration()SetLevel(string level)— change log level at runtime
Sink control:
EnableConsoleLogging(),DisableConsoleLogging()EnableFileLogging(),DisableFileLogging()
Properties:
CurrentLogFile— path to the current log fileConfigurationUpdated— event triggered when config file changes
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Newtonsoft.Json (>= 13.0.3)
- Serilog (>= 3.0.1)
- Serilog.Extensions.Logging (>= 3.1.0)
- Serilog.Sinks.Console (>= 4.1.0)
- Serilog.Sinks.File (>= 5.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DotLogs:
| Package | Downloads |
|---|---|
|
DotLogs.AspNet
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.