https://github.com/aditya119/configurablelogger
An easy-to-use and configurable logger
https://github.com/aditya119/configurablelogger
csharp-library dotnet5 logger nuget-package
Last synced: 2 months ago
JSON representation
An easy-to-use and configurable logger
- Host: GitHub
- URL: https://github.com/aditya119/configurablelogger
- Owner: aditya119
- License: mit
- Created: 2020-12-15T17:05:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-24T12:10:50.000Z (over 5 years ago)
- Last Synced: 2025-12-31T05:00:31.377Z (6 months ago)
- Topics: csharp-library, dotnet5, logger, nuget-package
- Language: C#
- Homepage:
- Size: 48.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Configurable Logger
ConfigurableLogger is an easy-to-use, and configurable logger.
It supports both synchronous and asynchronous logging.
---
### Installation
ConfigurableLogger can be installed from Nuget.
---
### Setup
Add `LogConfigModel` as a singleton service to provide required configurations.
- `LogConfigModel.LogLevel` can have value "Error", "Information", or "Debug".
- `LogConfigModel.LogFolder` stores the path to folder where log files will be stored. Use "@Console" to log to console.
- `LogConfigModel.LogFilenamePrefix` stores a prefix for the generated log files. Default is set to "app". Sample log file name `app_16-Dec-2020.log`.
Use `services.AddConfigurableLogger(logConfigModel)` in `Startup.ConfigureServices`.
Inject `ILoggingService` where necessary and log data.
### Usage
#### Methods:
- `void LogDebug(string message)`
- `void LogDebug(string message, T model) where T : class`: Logs a serialization of the passed class along with the message
- `Task LogDebugAsync(string message)`
- `Task LogDebugAsync(string message, T model) where T : class`
- `void LogInformation(string message)`
- `Task LogInformationAsync(string message)`
- `void LogError(Exception exception)`: Logs the details and stack-trace of the exception passed as parameter.
- `Task LogErrorAsync(Exception exception)`