Code Coverage by Clover.NET

Comma delimiter

View: New views
6 Messages — Rating Filter:   Alert me  

Comma delimiter

by dwmcqueen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There must be an easy answer - but I can't figure it out.  

I just want commas to be the delimiter in my csv file instead of pipes, yet even this config still yields pipes:

<configuration>
  <configSections>
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
    <section name="Settings" type="System.Configuration.NameValueSectionHandler" />
  </configSections>
  <nlog>
    <targets>
      <target name="console" type="Console" />
      <target name="file" type="File" delimiter="Comma" filename="${basedir}/logs/${date:format=yyyy-MM-dd}_${level}_log.txt" />

    </targets>
    <rules>
      <logger name="*" levels="Info,Warn,Error" writeTo="File" />
      <logger name="*" level="Debug" writeTo="file" />
      <logger name="*" level="Fatal" writeTo="file" />
    </rules>
  </nlog>

Shouldn't "delimiter="Comma" " fix that?


Re: Comma delimiter

by dwmcqueen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In addition, my settings are for "," delimiters (in my Regional Settings), but I keep getting pipes.

Re: Comma delimiter

by Jaroslaw_Kowalski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try this:

<?xml version="1.0" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <targets>
        <target name="csv" xsi:type="File" fileName="${basedir}/file.csv">
            <layout xsi:type="CSVLayout" delimiter="Auto|Comma|Semicolon|Tab|Pipe|Space|Custom">
                <column name="time" layout="${longdate}" />
                <column name="message" layout="${message}" />
                <column name="logger" layout="${logger}"/>
                <column name="level" layout="${level}"/>
            </layout>
        </target>
    </targets>

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

Re: Comma delimiter

by dwmcqueen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you - when I do that I get quotes around the "message" - anyway to removes this?

Re: Comma delimiter

by Jaroslaw_Kowalski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just put quoting="None" in <layout>

Re: Comma delimiter

by Jaroslaw_Kowalski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

LightInTheBox - Buy quality products at wholesale price