windows-servicestopshelfserilog

Serilog in Windows-Service not writing to logfile


I am using Serilog within an TopShelf Service, logging to the console and a rolling file. When running the service in a console my messages are written to the logfile, but when I install the service and run it no logging occurs. Is there anything special I need to configure? The file is written to the binaries folder under ".\logs\log-{date}.txt".


Solution

  • I had a very similar issue. In my case, the problem was with relative paths. I just had to specify the absolute path. Now it works like a charm.

    WriteTo.RollingFile(
      AppDomain.CurrentDomain.BaseDirectory + "\\logs\\log-{Date}.log"
    )