Gleeman.EffectiveLogger.ConsoleFile 2.0.1

dotnet add package Gleeman.EffectiveLogger.ConsoleFile --version 2.0.1                
NuGet\Install-Package Gleeman.EffectiveLogger.ConsoleFile -Version 2.0.1                
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="Gleeman.EffectiveLogger.ConsoleFile" Version="2.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Gleeman.EffectiveLogger.ConsoleFile --version 2.0.1                
#r "nuget: Gleeman.EffectiveLogger.ConsoleFile, 2.0.1"                
#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 Gleeman.EffectiveLogger.ConsoleFile as a Cake Addin
#addin nuget:?package=Gleeman.EffectiveLogger.ConsoleFile&version=2.0.1

// Install Gleeman.EffectiveLogger.ConsoleFile as a Cake Tool
#tool nuget:?package=Gleeman.EffectiveLogger.ConsoleFile&version=2.0.1                

Gleeman Effective Logger File and/or Console

dotnet CLI

$ dotnet add package Gleeman.EffectiveLogger.ConsoleFile --version 2.0.1
Program.cs
using Gleeman.EffectiveLogger.ConsoleFile.Configurations;
builder.Services.AddConsoleFileLog(settings =>
{
    settings.WriteToFile = true;
    settings.WriteToConsole = true;
    settings.FilePath = "File path is here";
    settings.FileName = "File name is here";
});
OR

appsettings.json

"LogSettings": {
  "WriteToConsole": true, // true or false
  "WriteToFile": true, // // true or false
  "FilePath": "File path is here",
  "FileName": "File name is here"
}
Program.cs
using Gleeman.EffectiveLogger.ConsoleFile.Configurations;
builder.Services.AddConsoleFileLog(builder.Configuration);

<hr>

Controller

 [ApiController]
 [Route("[controller]")]
 public class WeatherForecastController : ControllerBase
 {
     private static readonly string[] Summaries = new[]
     {
     "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
 };

     private readonly IEffectiveLogger<WeatherForecastController> _logger;

     public WeatherForecastController(IEffectiveLogger<WeatherForecastController> logger)
     {
         _logger = logger;
     }

     [HttpGet(Name = "GetWeatherForecast")]
     public IEnumerable<WeatherForecast> Get()
     {

         _logger.Info($"{Request.Path} - {Request.Method} - Status: {Response.StatusCode}");

         return Enumerable.Range(1, 5).Select(index => new WeatherForecast
         {
             Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
             TemperatureC = Random.Shared.Next(-20, 55),
             Summary = Summaries[Random.Shared.Next(Summaries.Length)]
         })
         .ToArray();
     }
 }

Console

Console

File

File

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
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
2.0.1 160 10/3/2023