anjosoft.filelogger 1.0.2

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

// Install anjosoft.filelogger as a Cake Tool
#tool nuget:?package=anjosoft.filelogger&version=1.0.2                

FileLogger

v.1.0.2

Logging provider for .net that allows you to log messages to text files

Installation

FileLogger is hosted at nuget.org. To Install, run: dotnet add package anjosoft.filelogger


Usage

import the anjosoft.filelogger namespace

Configure your log levels:

{
  "Logging": {
    "File": {
      "LogLevel": {
        "Default": "Information",
        "Microsoft": "Error"
      }
    }
  },
  "AllowedHosts": "*"
}

Add FileLogger and configure your logger options (Program.cs):

builder.Logging.AddFileLogger(options =>
    builder.Configuration.GetSection("Logging").GetSection("File").GetSection("Options").Bind(options)
);

By default, the logger will place logs in the applications’s root directory, inside a folder called “application_logs”. The default file format is UtcDateTime.log, for example, “2024-01-01.log”. To override the default log directory and/or file name format, you can specify a value for FolderPath and/or FilePath in your settings file. For example:

{
  "Logging": {
    "File": {
      "Options": {
        "FolderPath": "\Users\Shared\AppLogs",
        "FilePath": "app_{date}.log"
      },
      "LogLevel": {
        "Default": "Information",
        "Microsoft": "Error"
      }
    }
  }
}
Example
...
using anjosoft.filelogger;

namespace myapp_api.Controllers
{
    [Route("items")]
    public class ItemsController(IItemService itemService, ILogger<FileLogger> fileLogger) : ControllerBase
    {
        private readonly IItemService itemService = itemService;
        private readonly ILogger<FileLogger> fileLogger = fileLogger;

        [HttpPost]
        public async Task<IActionResult> Post([FromBody] ItemDTO item)
        {
            fileLogger.LogInformation("Posting a new item");
            ...
        }
        ...
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.2 140 3/20/2024
1.0.1 123 2/19/2024