A logger without the noise. No xml configs allowed.
Reading from a config is out of scope, use whatever config you want or statically set it up.
- Nuget Install FluentLogger
- In your Startup.cs (or entry point)
LogFactory.Init(
//Add as many loggers as you like
//Daily is deprecated, use MaximumFileSizeRoller instead
//new DailyLogRoller(@"C:\Users\marti\AppData\Roaming\911Cellular", LogLevel.Trace),
new MaximumFileSizeRoller(@"C:\Users\marti\AppData\Roaming\911Cellular", LogLevel.Trace, 2, 3 )
,new ConsoleLogger(LogLevel.Trace)
,new SmtpLogger(smtpClient, "errors@fluentlogger.com", "support@somewhere.com", LogLevel.Critical)
);
Then wherever you would like to use your logger.
ILog logger = LogFactory.GetLogger();
logger.Trace(
try{
MakeAnError();
}catch(Exception ex){
logger.Error("Unexpected error in MakeAnError", ex);
}
try{
DoSomeFatalThing();
}catch(Exception ex){
logger.Fatal(ex);
}