I use NLog in my asp.net core 2.0 applications, and I want to deploy it to Ubuntu. I can find lots of threads and articles, but all of them are deploy in Windows.
My nlog.config snippet looks as below,
<target xsi:type="File" name="ownlog" fileName="${var:configDir}\nlog-own.log"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}| ${message} ${exception}" />
and in my Startup.cs file, I set the configDir as below,
LogManager.Configuration.Variables["configDir"] = "\\var\\log";
It doesn't work. Anyone can help? How can I store the log file in \var\log folder?
Thanks
You'll have to change your path from double backslash to a single slash. If you want to keep both environments, you can do something like this:
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
// use windows path
else
// use linux path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With