FluentDocker icon indicating copy to clipboard operation
FluentDocker copied to clipboard

Logging issue on .netcore applications

Open Diggzinc opened this issue 4 years ago • 2 comments

Problem

Logs don't work under .netcore regarding of the configuration used.

Detailed Explanation

Doesn't matter how much I change the configuration for the logger based on the Microsoft documentation, be it through the appsettings.json or through environment variables, I can never get the logger to output the issued commands to the System.Diagnostics.Trace.Listeners.

After digging through the source code, I've found that for .netcore applications the code logs using the Trace log level as shown on the following line. https://github.com/mariotoffia/FluentDocker/blob/97733b63c6a243dddfaa8a7d41fb9d6a04ec6d81/Ductus.FluentDocker/Common/Logger.cs#L22

But then the provided provider is injected with the use of the .AddDebug() extension method which by default uses a minimum log level of Information. https://github.com/mariotoffia/FluentDocker/blob/97733b63c6a243dddfaa8a7d41fb9d6a04ec6d81/Ductus.FluentDocker/Common/Logger.cs#L33

Due to this, for .netcore all the logs are dropped due to the filter, I've compiled it myself and changed the LogLevel to Trace and was then able to get the logs on the Listeners as expected.

Possible Solution

Change the LogLevel filter on the Logger component.

Why this is a problem (for me)

Currently, one of my build machines is printing the docker-compose up help documentation as an error instead of creating the stack. I want to be able to see what is the command that is being issued in order to see what is the problem.

Any input would be appreciated. Thanks in advance 😄

Diggzinc avatar Jan 08 '21 13:01 Diggzinc

Hi and thanks! :) - can you do a PR on this issue?

mariotoffia avatar Jan 14 '21 18:01 mariotoffia

Yes, I'll sort it out this weekend :)

Diggzinc avatar Jan 14 '21 18:01 Diggzinc