1
votes

I am using NLog to log all my .NET applications. And I am looking for a software which can help me to view these long logs easily. So Legit Log Viewer comes to me. However, I am not able to view the log files, the Log Viewer says "unsupported log format". The following are my NLog.conf file and Legit Log Viewer layout file. Can anyone help me to figure out the mistake?

NLog.config target layout

layout="${level} | ${longdate} | ${callsite:className=true:fileName=false:includeSourcePath=false:methodName=true} | ${message} ${exception:format=tostring}"

My Legit Log Viewer Layout file.

<Description>
${level} | ${longdate} | ${logger} | ${message}
</Description>
<LogLine>
  <Fields>
<LogFieldFormat Name="Level" FieldType="String" Delimiter="|" FilterColumn="true" HighlightRows="true" />
<LogFieldFormat Name="DateTime" FieldType="DateTime" Delimiter="|" Format="yyyy-MM-dd HH:mm:ss.ffff" />
<LogFieldFormat Name="Logger" FieldType="String" Delimiter="|" />
<LogFieldFormat Name="Message" FieldType="String" />
  </Fields>
</LogLine>
1

1 Answers

2
votes

I've fixed XML config to support your log format.

<?xml version="1.0" encoding="utf-8" ?>
<LogFormat xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:xsd="http://www.w3.org/2001/XMLSchema"
           xmlns="http://www.legitlog.com/LogFormatSchema.xsd"
           FormatName="NLog (Joe Melbourne)">
  <Description>
    ${level} | ${longdate} | ${callsite:className=true:fileName=false:includeSourcePath=false:methodName=true} | ${message} ${exception:format=tostring}
  </Description>
  <LogLine>
    <Fields>
      <LogFieldFormat Name="Level" FieldType="String" Delimiter="| " FilterColumn="true" HighlightRows="true" />
      <LogFieldFormat Name="DateTime" FieldType="DateTime" Delimiter=" |" Format="yyyy-MM-dd HH:mm:ss.ffff" />
      <LogFieldFormat Name="Callsite" FieldType="String" Delimiter="|" />
      <LogFieldFormat Name="Message" FieldType="String" Delimiter="&#xD;&#xA;" Multiline="true" />
    </Fields>
  </LogLine>
</LogFormat>

There were odd spaces around date, so I changes delimiters to consume them. Also I added delimiter for the last field and made it to support multiple lines per message.

In the coming update I'll make log viewer to trim spaces automatically around dates and numbers.

P.S. Please don't hesitate to ping me via email on LL website to help you.