Nlog: File header name with columns names in CSV log

Created on 17 May 2016  路  4Comments  路  Source: NLog/NLog

Hi!

Is it possible to create CSV log file with header name and in next row with columns names.

something like that

SomeString
Column1,Column2,Column3
Value1,Value2,Value3
Value4,Value5,Value6

Type: Question

NLog version: 4.3.4

Platform: .Net 4.5.2

I tried something like that, but if I put header in layout tag then I'll get only "SomeString" without columns names.

Current NLog config

<target name="AppLog" xsi:type="File" fileName="${basedir}/AppLog.csv" encoding="utf-8">
     <layout xsi:type="CsvLayout" delimiter="Comma" withHeader="true" header="SomeString">  
          <column name="Column1" layout="${longdate}" />
          <column name="Column2" layout="${windows-identity}" />
          <column name="Column3" layout="" />  
     </layout>
</target>
question

Most helpful comment

@304NotModified How about

header="SomeString${newline}Column1,Column2,Column3"

Of course the column names are then hard-coded into the string, but at least it does the job, or am I missing something?

All 4 comments

Too bad that isn't possible. If you send a feature request, please think how we should configure it (backwards-compatible)

@304NotModified How about

header="SomeString${newline}Column1,Column2,Column3"

Of course the column names are then hard-coded into the string, but at least it does the job, or am I missing something?

That's a nice work around :)

That's working exactly how I wanted, Thank you very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FaMouZx3 picture FaMouZx3  路  3Comments

ericnewton76 picture ericnewton76  路  3Comments

Jerefeny picture Jerefeny  路  3Comments

vasumsit picture vasumsit  路  3Comments

imanushin picture imanushin  路  3Comments