Skip to content
Kirill edited this page Jun 6, 2020 · 7 revisions

Bootstrap

var dependencyProvider = new DependencyCollection()
     .AddLogger()                                // logger infrastructure
     .AddDefaultConsoleLogWriter(LogLevel.Debug) // write logs to console output
     .AddDefaultFileLogWriter("mylogs.log")      // write logs to file
     .AddDefaultLogEnrichers()                   // log level, sender, timestamp
     .BuildProvider();

Resolve logger

var logger = dependencyProvider.Get<ILogger<BooRepository>>();

Write logs

_logger.Debug("My log message with {arg1}, {arg2} and more", arg1, arg2);
Clone this wiki locally