I am trying to wire-up serilog using the app settings package and when I run my program Serlog is complaining it cannot find the RollingFile assembly. I did not have this problem using a single sink but multiple it giving me fits:
<!-- Serilog Configuration -->
<add key="serilog:using:Email" value="Serilog.Sinks.Email" />
<add key="serilog:using:RollingFile" value="Serilog.Sinks.RollingFile" />
<!-- Configure Serilog Email Sink -->
<add key="serilog:write-to:Email"/>
<add key="serilog:write-to:Email.mailServer" value="***" />
<add key="serilog:write-to:Email.toEmail" value="***" />
<add key="serilog:write-to:Email.fromEmail" value="***" />
<add key="serilog:write-to:Email.mailSubject" value="Notification" />
<add key="serilog:write-to:Email.restrictedToMinimumLevel" value="Debug" />
<!-- Configure Serilog RollingFile Sink -->
<add key="serilog:write-to:RollingFile" />
<add key="serilog:write-to:RollingFile.restrictedToMinimumLevel" value="Debug" />
<add key="serilog:write-to:RollingFile.pathFormat" value="C:\Logs\comply360-user-mgmt-{Date}.txt" />
<add key="serilog:write-to:RollingFile.outputTemplate" value="{Timestamp:HH:mm:ss} [{Level}] [{SourceContext}] [{CorrelationId}] {Message}{NewLine}{Exception}" />
You have to use prefix in web.config and in Configuration like this
Web.Config
<!-- Serilog Configuration -->
<add key="email:serilog:using:Email" value="Serilog.Sinks.Email" />
<add key="file:serilog:using:RollingFile" value="Serilog.Sinks.RollingFile" />
<!-- Configure Serilog Email Sink -->
<add key="email:serilog:write-to:Email"/>
<add key="email:serilog:write-to:Email.mailServer" value="***" />
<add key="email:serilog:write-to:Email.toEmail" value="***" />
<add key="email:serilog:write-to:Email.fromEmail" value="***" />
<add key="email:serilog:write-to:Email.mailSubject" value="Notification" />
<add key="email:serilog:write-to:Email.restrictedToMinimumLevel" value="Debug" />
<!-- Configure Serilog RollingFile Sink -->
<add key="file:serilog:write-to:RollingFile" />
<add key="file:serilog:write-to:RollingFile.restrictedToMinimumLevel" value="Debug" />
<add key="file:serilog:write-to:RollingFile.pathFormat" value="C:\Logs\comply360-user-mgmt-{Date}.txt" />
<add key="file:serilog:write-to:RollingFile.outputTemplate" value="{Timestamp:HH:mm:ss} [{Level}] [{SourceContext}] [{CorrelationId}] {Message}{NewLine}{Exception}" />
Startup.cs
Log.Logger = new LoggerConfiguration()
.ReadFrom
.AppSettings("email")
.ReadFrom
.AppSettings("file")
.CreateLogger()
figured it out. i had to remove the rolling file using statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With