Hi All,
Any suggestions on how could we attach the NLog.config to a docker-compose.yml file so that it generates an “NLog_Internal.txt” on the host machine and we can see all the application logs in that file?
In other words, is there a way we could extract the logs of an application running inside a Docker container using NLog on a specified location (local disk or cloud)?
I have tried creating an ASP.NET Core application with the following NLog.config file:
<?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"
throwConfigExceptions="true"
internalLogLevel="Trace"
internalLogToConsole="true">
<variable name="dockerlogDirectory" value="/data/logs/app"/>
<targets>
<target xsi:type="File" name="ownFile" fileName="${dockerlogDirectory}/MyCustomLog-${shortdate}.log"
layout="${longdate}|${logger}|${uppercase:${level}}|${threadid}:${threadname}|${message} ${exception}" />
<target xsi:type="Console" name="console" />
<target xsi:type="Null" name="blackhole" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="console" />
<logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />
<logger name="*" minlevel="Info" writeTo="ownFile" />
</rules>
</nlog>
Thanks.