Код: Выделить всё
var logger = new LoggerConfiguration()
.Enrich.WithProperty("Assembly", assembly?.Name)
.Enrich.FromLogContext()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Debug)
.WriteTo.Console(
theme: Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme.Code,
formatProvider: CultureInfo.CurrentCulture,
outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff}][{Level:u3}] {Message:lj} {NewLine}{Exception}",
restrictedToMinimumLevel: LogEventLevel.Debug)
.WriteTo.File(
path: "Logs/log-.log",
outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff}][{Level:u3}] {Message:lj} {NewLine}{Exception}",
rollingInterval: RollingInterval.Day,
restrictedToMinimumLevel: LogEventLevel.Debug,
formatProvider: CultureInfo.CurrentCulture)
.WriteTo.Sink(new WebSocketSink(logChannel), LogEventLevel.Debug)
.WriteTo.Seq("http://localhost:5341")
.CreateLogger();
операторы протоколирования не отображаются ни на консоли, ни в файле.
Но когда я изменю его на
Код: Выделить всё
Log.logger = new LoggerConfiguration()..Вот отрывок из класса, который я использую ILogger в качестве аргумента.
Код: Выделить всё
public class MyService(IDeviceIO devIO, ILogger logger) : IMyService
{
///
public void OpenDevice(string host)
{
logger.LogInformation("Device is being opened!");
devIO.Open(host);
}
...
Подробнее здесь: https://stackoverflow.com/questions/786 ... sole-or-in
Мобильная версия