Logging is an important part of modern application development, regardless of the platform targeted. This is why easy-logger is here to make log integration much easier. This library aims to provide easy logging in .netcore ^3.1 web application.
- Install-Package eazy-logger
eazy-logger is based on channels
. Each channel represents a specific way of writing application logs information.
Use the enabled
property on the LoggerOption to enable or disable and log
to any channel defined here - [appsettings]
- By default File logging is set to true with path Logs/logs.txt.
Add UseEazyLogging()
to the web host builder in BuildWebHost().
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseEazyLogging()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
Once you have configured the
UseEazyLogging()
in the Program.cs file, you're ready to define theLoggerOptions
in theapp.settings.json
.
"LoggerOptions": {
"name": "eazy-api",
"ignoredPaths": [ "logs", "/ping", "/metrics" ],
"level": "information",
"file": {
"enabled": true,
"path": "Logs/logs.txt",
"interval": "day"
},
"seq": {
"enabled": false,
"url": "http://localhost:5341",
"token": "secret"
},
"database": {
"enabled": true,
"name": "Db-Name",
"table": "Logs",
"instance": "SQL-Instant-Name",
"userName": "sudo",
"password": "root",
"encrypt": "False",
"trustedConnection": "False",
"trustServerCertificate": "True",
"integratedSecurity": "SSPI"
}
}
Please do open issues if you spot any bugs, or would like to suggest new features/changes.