Nlog: Log4JXmlEventLayout exports a <nlog:properties /> tag

Created on 3 May 2017  路  3Comments  路  Source: NLog/NLog

Hello,

So, I have nlog 4.4.8 installed, and I am using this target in my app.config:

<target name="logFile" xsi:type="File" fileName="${logDirectory}/log.xml" archiveFileName="${logDirectory}/log.${shortdate}.{#####}.xml" archiveNumbering="Sequence" archiveEvery="Day" archiveAboveSize="10240000" keepFileOpen="false" maxArchiveFiles="1000"> <layout xsi:type="Log4JXmlEventLayout" /> </target>

What happens (with the 4.4.8 release, with an older one it worked fine) is that this element ends up somehow in the XML, and is becomes invalid, and YALV! cannot load it:

<nlog:properties />

Not sure if this is important or not, but I also have a <log4j:properties> element, and this one is valid.

Thank you

bug

Most helpful comment

NLog 4.4.9 is in the deploy pipeline! Will be online in an hour!

All 3 comments

Breaking change was introduced with #2017. The workaround is to specify the layoutrenderer directly:

<target name="logFile" xsi:type="File" fileName="${logDirectory}/log.xml" archiveFileName="${logDirectory}/log.${shortdate}.{#####}.xml" archiveNumbering="Sequence" archiveEvery="Day" archiveAboveSize="10240000" keepFileOpen="false" maxArchiveFiles="1000" layout="${log4jxmlevent:includeNLogData=false}">

Will make a new PR to fix this regression.

NLog 4.4.9 is in the deploy pipeline! Will be online in an hour!

I can confirm that this is working with Yet Another Log4Net Viewer:

<targets>
    <target name="logFile" xsi:type="File" fileName="${basedir}/Logs/${shortdate}.xml"
            archiveFileName="${basedir}/Logs/log.${shortdate}.{#####}.xml" archiveNumbering="Sequence"
            archiveEvery="Day" archiveAboveSize="10240000" keepFileOpen="false" maxArchiveFiles="1000"
            layout="${log4jxmlevent:includeNLogData=false}"></target>
</targets>

<rules>
    <logger name="*" minlevel="Debug" writeTo="logFile" />
</rules>

My slightly changed version will save the files in the {ApplicationDirectory}/Logs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BobSeu picture BobSeu  路  3Comments

JustArchi picture JustArchi  路  3Comments

imanushin picture imanushin  路  3Comments

geedsen picture geedsen  路  3Comments

sszost picture sszost  路  3Comments