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
<PackageReference Include="anjosoft.filelogger" Version="1.0.2" />
paket add anjosoft.filelogger --version 1.0.2
#r "nuget: anjosoft.filelogger, 1.0.2"
// 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 | 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. |
-
net8.0
- Microsoft.Extensions.Configuration.Json (>= 8.0.0)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.