Nlog: XML Initialization / XML Header

Created on 11 Sep 2019  路  3Comments  路  Source: NLog/NLog

Is there a way in the XML output of NLog to also specify the XML header/initialisator (<?xml version="1.0" encoding="utf-8" ?>)? Or is that not possible?

Like this:

<?xml version="1.0" encoding="utf-8" ?>
<logevent time="2019-09-11 11:28:42.5461" level="ERROR"><message>zebgevv</message><location class-name="MyClass"/></logevent>
<logevent time="2019-09-11 11:36:22.6371" level="ERROR"><message>shshsdfbvsd</message><location class-name="MyClass"/></logevent>
<logevent time="2019-09-11 11:41:17.0781" level="ERROR"><message>dshfsghs</message><location class-name="MyClass"/></logevent>
question xml-layout

Most helpful comment

Thanks that worked :)

All 3 comments

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

If you are using the File-Target. Then you can configure a Header-Layout:

<target name="myXml" xsi:type="File"
    fileName="myXmlFile.txt"
    encoding="utf-8"
    header="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;" />

Thanks that worked :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vasumsit picture vasumsit  路  3Comments

imanushin picture imanushin  路  3Comments

haythamabutair picture haythamabutair  路  3Comments

sszost picture sszost  路  3Comments

BobSeu picture BobSeu  路  3Comments