YG.LogProvider
2.2.3
dotnet add package YG.LogProvider --version 2.2.3
NuGet\Install-Package YG.LogProvider -Version 2.2.3
<PackageReference Include="YG.LogProvider" Version="2.2.3" />
<PackageVersion Include="YG.LogProvider" Version="2.2.3" />
<PackageReference Include="YG.LogProvider" />
paket add YG.LogProvider --version 2.2.3
#r "nuget: YG.LogProvider, 2.2.3"
#:package YG.LogProvider@2.2.3
#addin nuget:?package=YG.LogProvider&version=2.2.3
#tool nuget:?package=YG.LogProvider&version=2.2.3
YGLogProvider
A simple log provider that follows ILogger pipeline and writes to a text file for .net 8.0
Installation
Include this package in the project file
Usage
Examples
in program.cs IoC Dependency Injection:
using YGLogProvider;
builder.Logging.ClearProviders();
builder.Logging.ClearProviders();
builder.Logging.AddYGLogProvider(options ⇒ { options.BaseDirectory = AppContext.BaseDirectory; options.FolderName = "Log"; options.MaxSize = 5000; options.MinimumLevel = LogLevel.Information; options.ExpiryDays = 1; });
in Blazor pages:
@inject ILogger<Home> _logger
and to log:
_logger.LogInformation("Test ...");
in controller:
take it from constructor parameter:
private readonly ILogger<TestController> _logger;
public TestController(ILogger<TestController> logger)
{
_logger = logger
}
and to log:
_logger.LogInformation("Test ...");
_logger.LogWarning("Test Warning ...");
Sample Log:
2024-05-14 16:26:41.049 [Information] Application started. Press Ctrl+C to shut down.
2024-05-14 16:26:41.067 [Information] Hosting environment: Development
2024-05-14 16:26:41.100 [Information] Content root path: C:\Temp\publish3
2024-05-14 16:26:41.301 [Information] Test ...
2024-05-14 16:26:43.282 [Information] Test Warning ...
Dependencies
Microsoft.Extensions.Logging.Abstractions
System.Diagnostics.EventLog
Contributing
Any new ideas on how to enhance this class without adding much complexity, please adhere to SOLID principle
License
This project is licensed under the MIT License(LICENSE).
| 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. net9.0 was computed. 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. |
-
net8.0
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- System.Diagnostics.EventLog (>= 8.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.
Removed redundent LogParms and use Exposed LogProviderOptions only