Serilog has a console sink for blazor webassembly
https://github.com/serilog/serilog-sinks-browserconsole
as suggested, there is no file support in Blazor/WASM
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Strange thing. Trying to configure Serilog for my Blazor WebAssembly app. There was no log file being created. The same configuration code is used in Blazor server app works fine.
The WebAssembly app uses SeriLog.Sinks.File while the server app uses Serilog.AspNetCore
var loggerConfiguration = new LoggerConfiguration()
.Enrich.WithProperty("Host", host)
.Enrich.WithProperty("Version", appVersion)
.Enrich.WithProperty("logger", appName)
.Enrich.WithProperty("thread", threadId)
.Enrich.WithProperty("Pid", pid)
.WriteTo.Console(outputTemplate: logAppenderConfig.OutputTemplate, levelSwitch: levelSwitch)
.WriteTo.File(
path: fqn,
restrictedToMinimumLevel: logAppenderConfig.EventLevel,
outputTemplate: logAppenderConfig.OutputTemplate,
fileSizeLimitBytes: logAppenderConfig.MaxFileSize,
levelSwitch: levelSwitch,
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: logAppenderConfig.RetentionCount,
rollOnFileSizeLimit: true
);
When I look at the loggerConfiguration in the debugger, I noticed that roller._directory = /
The file name then also starts with /, which doesn't work well with Windows.
Serilog has a console sink for blazor webassembly
https://github.com/serilog/serilog-sinks-browserconsole
as suggested, there is no file support in Blazor/WASM