Layout with Tab-Character

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Layout with Tab-Character

MyKey9815
Hello,

I using NLog and want to insert a Tab-Charater in the layout definition but I dind´t find the right way.

Here my actual config:

  <targets>
    <target name="file" xsi:type="File" fileName="${basedir}/log.txt"
            layout="${longdate} ${level} ${message} ${exception:format=tostring}" />
  </targets>

Can someone help me? I want following result

layout="${longdate} TAB-Chr ${level} TAB-Chr ${message} TAB-Chr ${exception:format=tostring}"
Reply | Threaded
Open this post in threaded view
|

Re: Layout with Tab-Character

Jarek Kowalski
Administrator
You can try one of the following things:
 
&#009; - XML entity for TAB
 
or use CSV Layout with delimiter="Tab"
 
    <target name="file" xsi:type="File" fileName="${basedir}/log.txt">
        <layout xsi:type="CSVLayout" delimiter="Tab">
          <column name="date" layout="${longdate}" />
          <column name="level" layout="${level}" />
          <column name="message" layout="${message}" />
          <column name="exception" layout="${exception:format=tostring}" />
        </layout>
    </target>
In the latter case, the layout will take proper care of encasing values in quotes when needed so the file you produce should be readable by standard CSV-capable applications such as Excel (including situations where you have multiline strings).
 
Let me know if it works for you.
 
Jarek
 
On Tue, Nov 10, 2009 at 6:26 AM, MyKey9815 [via NLog Forum] <[hidden email]> wrote:
Hello,

I using NLog and want to insert a Tab-Charater in the layout definition but I dind´t find the right way.

Here my actual config:

  <targets>
    <target name="file" xsi:type="File" fileName="${basedir}/log.txt"
            layout="${longdate} ${level} ${message} ${exception:format=tostring}" />
  </targets>

Can someone help me? I want following result

layout="${longdate} TAB-Chr ${level} TAB-Chr ${message} TAB-Chr ${exception:format=tostring}"


View message @ http://n2.nabble.com/Layout-with-Tab-Character-tp3979987p3979987.html
To start a new topic under NLog Forum, email [hidden email]
To unsubscribe from NLog Forum, click here.


NLog Blog
Reply | Threaded
Open this post in threaded view
|

Re: Layout with Tab-Character

MyKey9815
Thank you,

now it better but my message has included tab-charachters and when I open it in Execl then the whole message is in one Column

I need for every part of my message a seperate column

Have you an idea?
Reply | Threaded
Open this post in threaded view
|

Re: Layout with Tab-Character

Karis
In reply to this post by Jarek Kowalski
Thanks very much Jarek for your timely tip. It worked for me. Many thanks also for a great logging framework.

K