I am using VS 2017, asp.net core 2.1, nlog 4.7.0.
My nlog.config is:-
<targets>
<target xsi:type="Debugger" name="debuglog" layout="${message}" />
</targets>
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="debuglog" />
</rules>
both appsettings.json and appsettings.development.json have the same entries as advised my the wiki page (https://github.com/NLog/NLog.Web/wiki/Missing-trace%5Cdebug-logs-in-ASP.NET-Core-2%3F):-
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Trace",
"Microsoft": "Information"
}
I must be doing something stupidly wrong, just cannot see it! Can anyone help?
Apologies, I lost the config bit:-
<targets>
<target xsi:type="Debugger" name="debuglog" layout="${message}" />
</targets>
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="debuglog" />
</rules>
(updated the opening post already - JV)
Try and enable the NLog Internal Logger, and see the output in c:\temp\nlog-internal.txt:
<nlog internalLogFile="c:\temp\nlog-internal.txt" internalLogLevel="Trace">
<targets>
<target xsi:type="Debugger" name="debuglog" layout="${message}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="debuglog" />
</rules>
</nlog>
See also https://github.com/NLog/NLog/wiki/Logging-troubleshooting
Maybe also check if the following global variable has value true:
System.Diagnostics.Debugger.IsLogging()
Maybe try using a different target. Ex OutputDebugString:
<nlog internalLogFile="c:\temp\nlog-internal.txt" internalLogLevel="Trace">
<targets>
<target xsi:type="OutputDebugString" name="debuglog" layout="${message}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="debuglog" />
</rules>
</nlog>
Hi snakefoot, sorry for the delay in responding, last week before xmas is crazy!
ok so i tried all three things you suggested - but there was nothing in the internal log, islogging was true and using the OutputDebugString type didn't make any difference.
however, i then realised that my log statement said LogInfo and (grasping at straws coz i thought that whatever log statement type i used it should go to the debug window if the log level was low enough), i added a logdebug statement directly below it, ran the code again and got TWO entries in the debug output window. it's like, loginfo was not interested in the debug output window until logdebug was there alongside it!
i even tried commenting logdebug back out again to see if it would stop loginfo, but now loginfo writes to the debug output window absolutely fine! so i am totally confused, but very happy it is working :) maybe logdebug did some kind of one-time initialisation of something that was missing, this is the first time i have used nlog so who knows. anyways, many thanks and happy xmas :)
Has your question being answered?
Hi 304NotModified, yes i think i am all good now - my reply just above showed how i stumbled across the solution. not sure why things happened that way, but am very happy they did :)
do i need to mark it as an answer or something or can i just click "close and comment" to close the issue?
I will close it :) Thanks for the feedback!
This question has not been answered. There was some sort of "magic" that happened, according to the discussion above, but that helps no one, sadly.
On top of that, the discussion of the "solution" is not sufficiently detailed.
"realised that my log statement said LogInfo" - what log statement? Somewhere in the code, not included in the discussion?
"i added a logdebug statement directly below it" - again what was the exact statement? There are several ways to generate log statements from NLog (including NLog.Fluent). Some examples of the actual code would be immensely useful.
Apparently this set of events caused some sort of implicit change to the configuration of Visual Studio. A comparison of the configuration files of VS may lead us to the setting that would be the actual answer to this problem.
Have you tried checking the internal log? If this is still an issue, please open a new issue
Most helpful comment
This question has not been answered. There was some sort of "magic" that happened, according to the discussion above, but that helps no one, sadly.
On top of that, the discussion of the "solution" is not sufficiently detailed.
"realised that my log statement said LogInfo" - what log statement? Somewhere in the code, not included in the discussion?
"i added a logdebug statement directly below it" - again what was the exact statement? There are several ways to generate log statements from NLog (including NLog.Fluent). Some examples of the actual code would be immensely useful.
Apparently this set of events caused some sort of implicit change to the configuration of Visual Studio. A comparison of the configuration files of VS may lead us to the setting that would be the actual answer to this problem.