NLog works fine on windows .Net Core application but not on Linux

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


NLog works fine on windows .Net Core application but not on Linux



I've got this nlog.config file in my .Net Core console application:


nlog.config




<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Error"
internalLogFile="c:tempIBTestinternal-nlog.txt">
<targets>
<target xsi:type="File" name="allfile" fileName="c:tempIBTestnlog-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}|${message} ${exception}" />
<target xsi:type="File" name="ownFile-web" fileName="c:tempIBTestnlog-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}| ${message} ${exception}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />
<target xsi:type="Null" name="blackhole" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="allfile" />
<logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>



When I start my application on windows it works fine and creates all log files that should be created.
However, when I deploy my app on Linux it doesn't work.



This is how my nlog.config file looks on Linux:




<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Info"
internalLogFile="/home/ib_tests_internal-nlog.log">
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="allfile" fileName="/home/ib_tests-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}|${message} ${exception}" />

<!-- another file log, only own logs. Uses some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="/home/ib_tests_nlog-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}| ${message} ${exception}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />

<!-- write to the void aka just remove -->
<target xsi:type="Null" name="blackhole" />
</targets>

<!-- rules to map from logger name to target -->
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />

<!--Skip Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>



I really don't get what's wrong. I checked the paths million of times, all files (at least the ones I think) have all rights to read/write.
I've tried dotnet publish and then dotnet app.dll in windows and it worked. When I start the application the same way on Linux it doesn't. And I'm really out of ideas. Seems that all I've been doing was copy-paste from samples I had. Does anyone have ideas what could be wrong? Or what else to check? or some manual way to create that log file and see if it runs? seriously been sitting half of the day to the point I thought I'm going to be fired


dotnet publish


dotnet app.dll





Any output in ib_tests_internal-nlog.log ? Have you tried to enable ThrowConfigExceptions ? Have you configured file-permissions correctly ? Are you able to write to files without NLog ?
– Rolf Kristensen
2 mins ago




ib_tests_internal-nlog.log


ThrowConfigExceptions









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived