NLog icon indicating copy to clipboard operation
NLog copied to clipboard

Missing logging output after application deployment with Microsoft LoggerFactory

Open qiqisteve opened this issue 4 years ago • 8 comments

           var loggerFactory = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config");

           var dataPath = Environment.GetEnvironmentVariable("DATAPATH");
           Console.WriteLine(@dataPath);
           if (!string.IsNullOrEmpty(dataPath))
           {
                   Console.WriteLine(@dataPath);
                   NLog.GlobalDiagnosticsContext.Set("aaa",@dataPath);
           }

qiqisteve avatar May 06 '22 09:05 qiqisteve

Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better!

welcome[bot] avatar May 06 '22 09:05 welcome[bot]

I cannot guess what you are trying to do based on that amount of input.

See also: https://github.com/NLog/NLog/wiki/Logging-troubleshooting

snakefoot avatar May 06 '22 16:05 snakefoot

Please add the requested info, so we could help you better! (This issue will be closed in 7 days)

repo-ranger avatar May 06 '22 16:05 repo-ranger

1 .use the command dotnet run -c release ,the gdc item configuration works, 2. use the command `dotnet build -c release ', then run the build output file, the gdc config item not works, the log file wasnot created image

image

qiqisteve avatar May 07 '22 07:05 qiqisteve

Try enabling https://github.com/NLog/NLog/wiki/Internal-logging (using internalLogLevel="Debug"), and compare the output from when it works and when it doesn't work.

Maybe the nlog.config cannot be loaded, maybe because the file is missing (Action = Copy if newer)

snakefoot avatar May 07 '22 08:05 snakefoot

Try enabling https://github.com/NLog/NLog/wiki/Internal-logging (using internalLogLevel="Debug"), and compare the output from when it works and when it doesn't work.

Maybe the nlog.config cannot be loaded, maybe because the file is missing (Action = Copy if newer)

image

qiqisteve avatar May 09 '22 03:05 qiqisteve

Both looks great. I'm guessing your problem is that LogLevel-filtering has changed between the two scenarios:

Check appsettings.json and also any environment-specific like appsettings.development.json. See also: https://github.com/NLog/NLog.Web/wiki/Missing-trace%5Cdebug-logs-in-ASP.NET-Core-6%3F

Notice NLog 5.0 will change so RemoveLoggerFactoryFilter = true becomes enabled by default, but you can already now explicitly enable it in UseNLog().

snakefoot avatar May 09 '22 05:05 snakefoot