Acontplus.Common.Logging
0.0.4
dotnet add package Acontplus.Common.Logging --version 0.0.4
NuGet\Install-Package Acontplus.Common.Logging -Version 0.0.4
<PackageReference Include="Acontplus.Common.Logging" Version="0.0.4" />
paket add Acontplus.Common.Logging --version 0.0.4
#r "nuget: Acontplus.Common.Logging, 0.0.4"
// Install Acontplus.Common.Logging as a Cake Addin #addin nuget:?package=Acontplus.Common.Logging&version=0.0.4 // Install Acontplus.Common.Logging as a Cake Tool #tool nuget:?package=Acontplus.Common.Logging&version=0.0.4
Acontplus.Common.Logging
Description
Acontplus.Common.Logging
is a library that provides an advanced logging system for .NET applications. It allows storing logs in local files, Amazon S3, or a database, depending on the configuration defined in appsettings.json
.
Installation
To install the library, run the following command in the NuGet Package Manager Console:
Install-Package Acontplus.Common.Logging
dotnet add package Acontplus.Common.Logging
Configuration
To enable and customize the logging system, edit the appsettings.json
file and add the following section:
"AdvancedLogging": {
"EnableLocalFile": true,
"Shared": false,
"Buffered": true,
"LocalFilePath": "logs/log-.log",
"RollingInterval": "Day",
"RetainedFileCountLimit": 7,
"FileSizeLimitBytes": 10485760, // 10MB in bytes
"EnableS3Logging": false,
"S3BucketName": "my-application-logs",
"S3AccessKey": "your-access-key",
"S3SecretKey": "your-secret-key",
"EnableDatabaseLogging": false,
"DatabaseConnectionString": "Server=...",
"MinimumLogLevel": "Information"
}
Configuration Options
- EnableLocalFile (bool): Enables or disables storing logs in local files.
- Shared (bool): Enables or disables shared log files.
- Buffered (bool): Enables or disables buffered logging.
- LocalFilePath (string): Path to the log file. It can include
{Date}
to generate a file per day. - RollingInterval (string): Interval to roll log files. Possible values:
Year
,Month
,Day
,Hour
,Minute
. - RetainedFileCountLimit (int): Number of log files to keep.
- FileSizeLimitBytes (int): Maximum size of the log file in bytes.
- EnableS3Logging (bool): Enables or disables storing logs in Amazon S3.
- S3BucketName (string): Name of the S3 bucket where logs will be stored.
- S3AccessKey (string): AWS access key for the S3 bucket.
- S3SecretKey (string): AWS secret key for the S3 bucket.
- EnableDatabaseLogging (bool): Enables or disables storing logs in a database.
- DatabaseConnectionString (string): Connection string to the database where logs will be stored.
- MinimumLogLevel (string): Minimum log level to be recorded. Possible values:
Trace
,Debug
,Information
,Warning
,Error
,Critical
.
Usage
Once configured, the logging system will activate according to the settings defined in appsettings.json
. It is recommended to check file access permissions, S3 configuration, and the database connection string to ensure proper functionality.
Inject in your services in program:
builder.Services.AddAdvancedLogging(builder.Configuration);
Requirements
- .NET 6 or higher
- Proper write permissions if
EnableLocalFile
is enabled. - AWS account with S3 permissions if
EnableS3Logging
is enabled. - Accessible database if
EnableDatabaseLogging
is enabled.
Contributions
Contributions to improve this library are welcome. To report bugs or suggestions, open an issue in the official repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contact
If you have any questions or need support, please feel free to contact us.
- Author: Ivan Paz
- Company: Acontplus S.A.S.
- Email: ifer343@gmail.com
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net9.0
- AWSSDK.Core (>= 3.7.401.8)
- AWSSDK.S3 (>= 3.7.413.3)
- Microsoft.Data.SqlClient (>= 6.0.1)
- Microsoft.Extensions.Configuration (>= 9.0.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.1)
- Microsoft.Extensions.Configuration.Json (>= 9.0.1)
- Microsoft.Extensions.DependencyInjection (>= 9.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.1)
- Microsoft.IdentityModel.Tokens (>= 8.3.1)
- Newtonsoft.Json (>= 13.0.3)
- Serilog (>= 4.2.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Extensions.Logging (>= 9.0.0)
- Serilog.Formatting.Compact (>= 3.0.0)
- Serilog.Settings.Configuration (>= 9.0.0)
- Serilog.Sinks.AmazonS3 (>= 1.5.3)
- Serilog.Sinks.Async (>= 2.1.0)
- Serilog.Sinks.Console (>= 6.0.0)
- Serilog.Sinks.File (>= 6.0.0)
- Serilog.Sinks.MSSqlServer (>= 8.1.0)
- System.IdentityModel.Tokens.Jwt (>= 8.3.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.