Search code examples
c#azureazure-service-fabricactorserilog

Serilog doesn't work in Reliable Actor Services


I have two Service Fabric application. The first is an Asp.Net Core Service Fabric, the second is an Actor Service that run with timer.

Both are set up with Serilog. The Asp.Net Core work very well. no problem there, but the second service, Actor Service, I use the same configurations and same nuget packages but Serilog doesn't save any log.

Add Config

<add key="serilog:using:Seq" value="Serilog.Sinks.Seq" />
    <add key="serilog:write-to:Seq.serverUrl" value="http://*****" />
    <add key="serilog:write-to:Seq.apiKey" value="UfKpKLicyZI3hGe7Vc" />
    <add key="serilog:using:RollingFile" value="Serilog.Sinks.RollingFile" />
    <add key="serilog:write-to:RollingFile.pathFormat" value="C:\File-{Date}.txt" />
    <add key="serilog:write-to:RollingFile.retainedFileCountLimit" value="10" />

Solution

  • The most likely cause here is that the Serilog Logger is not being Dispose()d before the process hosting the actor shuts down (if you're setting up the static Log class instead of using a logger instance directly, this is achieved with Log.CloseAndFlush()).