New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MappedDiagnosticsLogicalContext issues with ASP.NET Core 2.2 InProcess hosting #3387
Comments
Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better! |
I guess the If you are using <target name="log4view" xsi:type="NLogViewer" address="tcp://127.0.0.1:878">
<parameter layout="${gdc:item=MyGlobalVar}" name="GlobalParam"/>
</target> |
We are currently doing this:
Where
Is the nested parameter technique you described still supported for Log4JXMLEvent Layout Renderer? Thanks for your quick response! |
<target name="log4view" xsi:type="NLogViewer" address="${var:logFacesUri}" includeMdlc="true" includeCallSite="true">
<parameter layout="${gdc:item=MyGlobalVar}" name="GlobalParam"/>
</target> And stop using Sadly enough then NLog.LogManager.Configuration?.AllTargets.OfType<NLogViewer>().ToList().ForEach(t => t.AppInfo = softwareName); |
Have created the following pull-requests:
|
I don't know how to thank you enough - it worked and is much cleaner than what I was doing before. Thank you so much! |
Happy you found a working solution. When the above PullRequests becomes part of NLog, then the config should become even easier/cleaner. |
Thanks again for your help. |
@SkinnySackboy NLog 4.6.4 has been released: https://www.nuget.org/packages/NLog/4.6.4 So now you can do the following with a pure NetworkTarget: <target name="logFaces" xsi:type="Network" address="${var:logFacesUri}">
<layout xsi:type="Log4JXmlEventLayout" includeMdlc="true" includeCallSite="true">
<parameter layout="${gdc:item=MyGlobalVar}" name="GlobalParam"/>
</layout>
</target> |
Thank you very much! |
@snakefoot I now see the following error: “Parameter includeCallSite not supported on Log4JXmlEventLayout” |
Looks like I need to make another Pull Request to also add support for IncludeCallSite :) NLog 4.6.4 only added support for using Parameters.
|
Have now created #3442 |
@SkinnySackboy Maybe this might work while waiting for PR to be merged/released: <target name="logFaces" xsi:type="Network" address="${var:logFacesUri}">
<layout xsi:type="Log4JXmlEventLayout" includeMdlc="true">
<renderer includeCallSite="true" />
<parameter layout="${gdc:item=MyGlobalVar}" name="GlobalParam"/>
</layout>
</target> |
Hi,
Until recently, we were using NLog with our ASP.NET Core app without issue. We have configured log4jxmlevent using the MappedDiagnosticsLogicalContext. This has always worked for us.
Recently we switched to ASP.NET Core InProcess hosting and suddenly our log4jxmlevent layout renderer is no longer including data that we had initially set on the MappedDiagnosticsLogicalContext, because MappedDiagnosticsLogicalContext for some reason now gets cleared. The same goes for MappedDiagnosticsLogicalContext. More specifically, when we set them and log at startup it’s fine, but once the app is up and running and requests come in on different threads both these dictionaries get cleared.
The only one that doesn’t get cleared is GlobalDiagnosticsContext, however to my knowledge the log4jxmlevent does not attempt to GetNames() from here at any point.
Has anyone got any idea how to solve this problem please as I’ve been banging my head against this for a few days now and cannot find a satisfactory solution?
Thanks.
The text was updated successfully, but these errors were encountered: