I wrote a c# (.NET 6.0) console application which is a queue consumer and writes dequeued messages into log file. Everything is fine in local but as i dockerize the app i cant see neither a log file nor a console message even if the message is rightly acknoledge from the queue.
Here is log4net.config file with 2 appender
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="FileAppender" />
<appender-ref ref="console" />
</root>
<appender name="console" type="log4net.Appender.ConsoleAppender">
<layout type="Elastic.CommonSchema.Log4net.EcsLayout, Elastic.CommonSchema.Log4net">
</layout>
</appender>
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\Users\t.domenici\source\repos\RabbitMqDemo\LogHandler\bin\Release\net6.0\Log\Log_" />
<lockingModel type="log4net.Appender.FileAppender+ExclusiveLock" />
<datePattern value="dd_MM_yyyy'.log'"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<staticLogFileName value="false"/>
<layout type="Elastic.CommonSchema.Log4net.EcsLayout, Elastic.CommonSchema.Log4net" />
</appender>
</log4net>
and here is the docker command to create a bind mount, which is correctly created
docker run -v C:/Users/********/source/repos/RabbitMqDemo/LogHandler/bin/Release/net6.0/Log:/app/LogHandler/Log -it --name LogHandler log-handler-image:1.0.0
Thanks in advance!
I succeded to write log and print message using log4net sdk by adding the WORKDIR /app/LogHandler command into the docker file. Now the file appears once the container is started and it is correctly update on every dequeued message. Even the console is working. Now it is time to create a volume to make the file persisting after conainer is switched off. Here are the Dockerfile and some results:
Thanks everybody for supporting me