CodeWithSaar.Extensions.Logging.File
1.0.0-beta2
See the version list below for details.
dotnet add package CodeWithSaar.Extensions.Logging.File --version 1.0.0-beta2
NuGet\Install-Package CodeWithSaar.Extensions.Logging.File -Version 1.0.0-beta2
<PackageReference Include="CodeWithSaar.Extensions.Logging.File" Version="1.0.0-beta2" />
paket add CodeWithSaar.Extensions.Logging.File --version 1.0.0-beta2
#r "nuget: CodeWithSaar.Extensions.Logging.File, 1.0.0-beta2"
// Install CodeWithSaar.Extensions.Logging.File as a Cake Addin #addin nuget:?package=CodeWithSaar.Extensions.Logging.File&version=1.0.0-beta2&prerelease // Install CodeWithSaar.Extensions.Logging.File as a Cake Tool #tool nuget:?package=CodeWithSaar.Extensions.Logging.File&version=1.0.0-beta2&prerelease
CodeWithSaar.Extensions.Logging.File
A file logger provider implementation for Microsoft.Extensions.Logging. At this moment, this package is very easy to use in debugging environment.
Refer to the Known-limitations before you use this in production.
Getting Started
Add NuGet Package:
dotnet add package CodeWithSaar.Extensions.Logging.File
In ASP.NET Core project, enable the logging provider:
... // Add services to the container. builder.Services.AddLogging(loggingBuilder =>{ loggingBuilder.AddFile(); }); ...
Check out the example project.
Run the application and see the log output to
output.log
.
Customization
Set a different file name
There are generally 2 ways to set log configurations.
By code:
builder.Services.AddLogging(loggingBuilder => { loggingBuilder.AddFile(opt => opt.OutputFilePath = "newfilename.log"); });
By configuration file (Typically, appsettings.json):
{ // General logging "Logging": { "LogLevel": { "Default": "Debug" }, // File provider overwrites "FileProvider": { // Output to output.v2.log file "OutputFilePath": "output.v2.log", // Specify a different logging level "LogLevel":{ "Default": "Information" } } } }
Set different logging levels
Logging levels could be set in through appsettings.json
/ appsettings.Development.json
or whatever the configuration providers in your project.
It would take the default settings like this:
{
// Logging Information or above to file
"Logging": {
"LogLevel": {
"Default": "Debug"
}
}
}
Or it could be set to it's own:
{
// Default logging level of Debug
"Logging": {
"LogLevel": {
"Default": "Debug"
},
"FileProvider":
{
// Output to output.v2.log file
"OutputFilePath": "output.v2.log",
// Specify a different logging level of Information for logs output to the file.
"LogLevel":{
"Default": "Information"
}
}
}
}
Known limitations
- Scope is not supported yet;
- There might be concurrency issues;
- File writing performance is not optimized;
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Logging.Configuration (>= 6.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.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 825 | 5/9/2022 |
1.0.0-beta6 | 250 | 5/2/2022 |
1.0.0-beta5 | 242 | 4/19/2022 |
1.0.0-beta4 | 214 | 4/12/2022 |
1.0.0-beta2 | 191 | 4/12/2022 |
1.0.0-beta1 | 190 | 4/12/2022 |