Serilog in Windows-Service not writing to logfile

Gope picture Gope · Oct 26, 2014 · Viewed 10.2k times · Source

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".

Best regards Gope

Answer

Michael picture Michael · May 5, 2015

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

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

Hope it helps!