Specify directory for Serilog rolling file path

Just put this before the creation of LoggerConfiguration:

Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;

Then File.path will be constructed based on the project root path.


The best place for services to write their logs is %PROGRAMDATA% which, by default, is in C:\ProgramData\.

Try:

<add key="serilog:write-to:RollingFile.pathFormat"
     value="%PROGRAMDATA%\ServerService\Logs\log-{Date}.txt" />

(Program Files is usually considered to be read-only, and writing stuff here will lead to oddities being left behind unexpectedly during uninstall.)