I have Serilog setup and logging in my application, however the date is not being appended to filename. The log file gets created as Log-.log
instead of Log-20220302.log
. Relevant code is shown below. The nuget package Serilog.Sinks.File
has been installed. Any ideas why?
public override void Bind(ref IContainer container)
{
container.Register(
() => new LoggerFactory(
new ILoggerProvider[]
{
new SerilogLoggerProvider(
new LoggerConfiguration()
.ReadFrom.AppSettings()
.Enrich.FromLogContext()
.CreateLogger()),
new DebugLoggerProvider(),
}).AddSerilog(),
DependencyScope.Singleton);
container.Register(typeof(ILogger<>), typeof(Logger<>), DependencyScope.Singleton);
}
Web.config
<appSettings>
<add key="serilog:using:File" value="Serilog.Sinks.File" />
<add key="serilog:write-to:File.path" value="C:\logs\Log-.log" />
<add key="serilog:write-to:File.rollingInterval" value="Day" />
</appSettings>
Notice the double period in the file name. Example output apilog.20220114.log