Suggested approaches for file paths when running on various platforms (Linux/Windows)

129 views
Skip to first unread message

Erick Thompson

unread,
Jan 27, 2017, 2:51:47 PM1/27/17
to Serilog
Hey,

I have a number of applications that log to file (usually rolling file). These applications are .net core, and will be deployed to both Windows and Linux containers. The application works great, but I'm not sure how to deal with file paths. For example, I want Windows to log "c:\logs\foo" and on Linux "\var\logs\foo". What is the suggested approach to dealing with platform specific file paths? 

Thanks,
Erick

nblum...@nblumhardt.com

unread,
Jan 27, 2017, 4:04:24 PM1/27/17
to Serilog
Hi Erick,

Writing the path into a config file (e.g. appsettings.json), or passing it as an environment variable, is the way to go here.

Hope this helps!
Nick

Erick Thompson

unread,
Jan 31, 2017, 11:58:03 PM1/31/17
to Serilog
Thanks Nick, that makes sense. 

I'm going to test the generation of filenames in Serilog (e.g., Rolling file). Hopefully it will just work out of the box :)

Thanks!
Reply all
Reply to author
Forward
0 new messages