Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net output in Docker logs

I''m trying to get log output (Console.WriteLine(..)) in my Docker logs, but I'm getting zero avail.

I've tried:

Console.WriteLine(..)

Trace.WriteLine(..)

Flushing the console, flushing the trace.

I can see these outputs in a VS output window when I'm debugging, so they go somoewhere.

I'm on windows Container, using microsoft/aspnet:4.7.1-windowsservercore-1709 and net4.7

These are the logs I get on container start

 docker logs -f exportapi
ERROR ( message:Cannot find requested collection element. )
Applied configuration changes to section "system.applicationHost/applicationPools" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"
like image 630
Stuart.Sklinar Avatar asked Feb 14 '18 16:02

Stuart.Sklinar


1 Answers

You have many good lateral options, like self-contained/server-contained executables (eg. Dotnet Core using microsoft/dotnet:runtime would proxy Console.WriteLine by default off the dotnet new web scaffold). Zero-configuration STDOUT logging has never been a common approach on IIS, but these modern options adopt it as best practice (logging should be a transparent backing service).

If you want or need a chain of three programs/assemblies to get your web service up (ServiceMonitor, W3SVC, and finally your assembly), then you need something like this: https://blog.sixeyed.com/relay-iis-log-entries-to-read-them-in-docker/

Overriding the entrypoint to tail more logs than the image does by default is unfortunately a common hack (not just in Microsoft land). So, in your case, I believe you need at least a trace listener config to emit Trace.WriteLine, and then the above approach to emit it: https://docs.microsoft.com/en-us/dotnet/framework/debug-trace-profile/how-to-create-and-initialize-trace-listeners

like image 200
nik.shornikov Avatar answered Sep 20 '22 06:09

nik.shornikov