YGLogProvider 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package YGLogProvider --version 1.0.0                
NuGet\Install-Package YGLogProvider -Version 1.0.0                
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="YGLogProvider" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add YGLogProvider --version 1.0.0                
#r "nuget: YGLogProvider, 1.0.0"                
#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 YGLogProvider as a Cake Addin
#addin nuget:?package=YGLogProvider&version=1.0.0

// Install YGLogProvider as a Cake Tool
#tool nuget:?package=YGLogProvider&version=1.0.0                

YGLogProvider

A simple log provider that writes to a text file for .net 8.0

Installation

Include this package in the project file

Usage

LogProvider logP = new LogProvider(Parm1, Parm2, Parm3, Parm4, Parm5); Parm 1: it will log any log equal to or higher than the LogLevel enum as specified. For example, Information will include Warning, Error, and Critical error Parm 2: relative folder for the log file Parm 3: log file base name Parm 4: number of days to keep this log file Parm 5: number of bytes before it starts to create a new log with base name and copy the maxed out log file into a new filename with datetime stamp

See sample code

Examples

in program.cs IoC Dependency Injection:

using YGLogProvider;

LogProvider logP = new LogProvider(LogLevel.Information, "../MyLog", "log.txt", 10, 50000); builder.Logging.ClearProviders(); // If you want to use just this log provider only for logging builder.Logging.AddProvider(logP);

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 ...");

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 ... 2024-05-14 16:26:43.877 [Information] Test ...

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 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
1.0.1 109 5/15/2024
1.0.0 100 5/15/2024

First Release - for .net 8 only