how to get line number in log

3 messages Options
Embed this post
Permalink
medabhi

how to get line number in log

Reply Threaded More More options
Print post
Permalink
Hi forum, i am a beginner in Nlog can some one guide me how do i print line numbers using Nlog
Boersnoes

Re: how to get line number in log

Reply Threaded More More options
Print post
Permalink
source file linenumbers or in numbers in front of your log file entries?

Source file: set the includeSourceInfo parameter of your target to true.
Source http://www.nlog-project.org/target.NLogViewer.html

Line numbers in log file I don't know by heart. Also, most txt viewers already give you line numbers.
ToniM

Re: how to get line number in log

Reply Threaded More More options
Print post
Permalink
Hello,

i developed NLog today, so i'm not really fit at using it.
I have 2 questions so far (i know, only the 1st is depending to this thread):
- how do i get the file name and the line number of the raised log event into my logfile?
- how can i seperate the layout (in target) coming from a logger.*Exception(...); call or not?


NLog.config - START:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <variable name="logDirectory" value="C:\temp" />
  <variable name="logLayout" value="[${longdate}][${callsite}][${windows-identity:domain=false}][${level}][${message}]'" />

  <targets>
    <target name="file" xsi:type="File"
        layout="${logLayout}"
        fileName="${logDirectory}/logfile.${windows-identity:domain=false}.log"
        archiveFileName="${logDirectory}/logfile.${windows-identity:domain=false}.{##}.log"
        includeSourceInfo="true"
        archiveEvery="None"
        archiveAboveSize="512"
        archiveNumbering="Rolling"
        maxArchiveFiles="5"
        concurrentWrites="true"
        keepFileOpen="false"
        encoding="iso-8859-1" />
    <target name="console" xsi:type="Console"
        layout="${logLayout}"
        includeSourceInfo="true" />
  </targets>

  <rules>
    <logger name="*" minlevel="Trace" writeTo="console" />
  </rules>

</nlog>
NLog.config - END


So, i hope you can help me.

But although: thanks!


Have a good one,
ToniM