Hi! Thanks for reporting this feature/bug/question!
Please keep / fill in the relevant info from this template so that we can help you as best as possible.
For .NET Core users, please check the platform support: https://github.com/NLog/NLog/wiki/platform-support
Type (choose one):
NLog version: All
Platform: .Net 4.0 / .Net 4.5
Current NLog config (xml or C#, if relevant)
<nlog>
<variable name="HeaderLayout" value="${longdate}|INFO|General|${threadid}|MachineName: '${machinename}', OS: '${gdc:item=os}', Platform: '${gdc:item=platform}' ProcessId: '${processid}', ProcessorCount: '${gdc:item=processorCount}', TotalMemory: '${gdc:item=totalMemory}', AppVersion: '${gdc:item=appVersion}'" />
<variable name="StandardLayout" value="${longdate}|${level:uppercase=true}|${logger}|${threadid}|${message}" />
<extensions>
<add assembly="Aprimo.Diagnostics.ApplicationInsights" />
</extensions>
<targets>
<target type="AsyncWrapper" name="asyncAprimoAi" overflowAction="Grow">
<target type="AprimoAITarget" name="aiTarget" />
</target>
<target type="AsyncWrapper" name="asyncFile" overflowAction="Grow">
<target name="file" type="File" fileName="${gdc:item=rootPath}\${machinename}.${gdc:item=appName}.log" archiveNumbering="Sequence" archiveAboveSize="10485760" maxArchiveFiles="10" archiveFileName="${gdc:item=rootPath}\Archives\${machinename}.${gdc:item=appName}.{#}.log" autoFlush="True">
<layout type="LayoutWithHeaderAndFooter">
<header type="SimpleLayout" text="${HeaderLayout}" />
<layout type="SimpleLayout" text="${StandardLayout}" />
<footer type="SimpleLayout" text= "" />
</layout>
</target>
</target>
<target type="AsyncWrapper" name="asyncEvent" overflowAction="Grow">
<target type="EventLog" name="event" log="${gdc:item=eventLog}" source="${gdc:item=appName}"/>
</target>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="asyncFile"/>
<logger name="*" minlevel="Error" writeTo="asyncEvent"/>
<logger name="*" minlevel="Warn" writeTo="asyncAprimoAi" />
</rules>
</nlog>
In case of a BUG:
-
What is the current result?
There is a large increase in memory consumption when the logging level is set to "Trace", and there are a large number of logging statements for verbose debugging in an application. This is leading to NLog objects (specifically the LogEventInfo object, and its associated string data) being placed in Gen2 or higher memory heaps where they persist longer than necessary, which in turn leads to high memory consumption, or even overflow.
-
What is the expected result?
The LogEventInfo objects should be destroyed after the event it written to the NLog targets that apply.
-
Did you checked the Internal log?
Yes.
-
Please post full exception details (message, stacktrace, inner exceptions)
There are no exception details for this issue. It will require a memory dump analysis to determine if the objects are being disposed of properly before they end up in higher generation memory heaps.
-
Are there any work arrounds? yes/no
The workaround for this issue is to turn logging levels up to "Warn" or above, and ensure that the underlying application is not making excessive logging calls that would cause additional NLog objects to be created.
-
Is there a version in which it did worked?
No.
-
Can you help us by writing an unit test?
N/A
Hi! Thanks for reporting this feature/bug/question!
Please keep / fill in the relevant info from this template so that we can help you as best as possible.
For .NET Core users, please check the platform support: https://github.com/NLog/NLog/wiki/platform-support
Type (choose one):
NLog version: All
Platform: .Net 4.0 / .Net 4.5
Current NLog config (xml or C#, if relevant)
In case of a BUG:
What is the current result?
There is a large increase in memory consumption when the logging level is set to "Trace", and there are a large number of logging statements for verbose debugging in an application. This is leading to NLog objects (specifically the LogEventInfo object, and its associated string data) being placed in Gen2 or higher memory heaps where they persist longer than necessary, which in turn leads to high memory consumption, or even overflow.
What is the expected result?
The LogEventInfo objects should be destroyed after the event it written to the NLog targets that apply.
Did you checked the Internal log?
Yes.
Please post full exception details (message, stacktrace, inner exceptions)
There are no exception details for this issue. It will require a memory dump analysis to determine if the objects are being disposed of properly before they end up in higher generation memory heaps.
Are there any work arrounds? yes/no
The workaround for this issue is to turn logging levels up to "Warn" or above, and ensure that the underlying application is not making excessive logging calls that would cause additional NLog objects to be created.
Is there a version in which it did worked?
No.
Can you help us by writing an unit test?
N/A