logging exception details

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

logging exception details

Chris Lajoie
I want to appologize now if this has been asked a hundred times
already, but I couldn't turn up any results on google. I to have a
detailed error log, but I don't understand how to do my format string
so it writes this information. The documentation
(http://www.nlog-project.org/lr.exception.html) does not show me how
to get those exception properties into the log file.
Here is an example of what I want it to look like -- this is how my
own logging class wrote exception to the error log:

Date/Time: 3/14/2005 10:47:28 AM     2779359
Extra Info: none specified
System.ComponentModel.Win32Exception: The system cannot find the file specified
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo
startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(String fileName, String arguments)
   at xxxx.FileUtility.TextEditor(String file, String title) in
FileUtility.cs:line 291

Any help would be appreciated. Thanks.

Chris


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
Reply | Threaded
Open this post in threaded view
|

RE: logging exception details

Francis1
Chris,

This is what I use:
<target name="error" type="File"
filename="${basedir}/../logs/${date:format=/yyyy-MM-dd/}log.txt"
layout="${longdate}|${level:uppercase=true}|${logger}|${callsite}|${message}
|${exception}|${stacktrace}" />

Francis



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
Reply | Threaded
Open this post in threaded view
|

Re: logging exception details

Jarek Kowalski
Administrator
Francis, just a tip:

There's a ${shortdate} layout renderer which is preferred over yyyy-MM-dd
because it's many times faster. So your filename can be rewritten as:

${basedir}/../logs/${shortdate}/log.txt

Jarek
----- Original Message -----
From: "Francis Gingras" <[hidden email]>
To: <[hidden email]>
Sent: Friday, April 07, 2006 9:00 PM
Subject: RE: [Nlog-list] logging exception details


> Chris,
>
> This is what I use:
> <target name="error" type="File"
> filename="${basedir}/../logs/${date:format=/yyyy-MM-dd/}log.txt"
> layout="${longdate}|${level:uppercase=true}|${logger}|${callsite}|${message}
> |${exception}|${stacktrace}" />
>
> Francis
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Nlog-list mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/nlog-list
>



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
NLog Blog
Reply | Threaded
Open this post in threaded view
|

Re: logging exception details

Chris Lajoie
In reply to this post by Francis1
thanks for the quick reply.
I tried that and it gave me all the info I wanted, but I would like to
be able to write out the stack trace on multiple lines (like it does
when you use the ToString() method).
I have 2 log files for my app, a detailed error log and a trace log
(which also logs very basic info on errors on a single line). I'm not
trying to squeeze as much info on one line as possible with the error
log, because generally I just scroll to the bottom to see the last
exception.

Does anyone have an example of how to use the exception layout
renderer that I linked in my original post?

Chris

On 4/7/06, Francis Gingras <[hidden email]> wrote:

> Chris,
>
> This is what I use:
> <target name="error" type="File"
> filename="${basedir}/../logs/${date:format=/yyyy-MM-dd/}log.txt"
> layout="${longdate}|${level:uppercase=true}|${logger}|${callsite}|${message}
> |${exception}|${stacktrace}" />
>
> Francis
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting language
> that extends applications into web and mobile media. Attend the live webcast
> and join the prime developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Nlog-list mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/nlog-list
>


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
Reply | Threaded
Open this post in threaded view
|

Re: logging exception details

Jarek Kowalski
Administrator
Chris,

This explains the usage of ${exception} layout renderer and its variants:

http://sourceforge.net/mailarchive/message.php?msg_id=11111027

Basically just try: ${exception:format=tostring}.

If you need any special format provider that isn't supported, add the
necessary code to "NLog\src\LayoutRenderers\Exception.cs" and post your
patch (or the entire file) to the mailing list. I will include it in future
releases of NLog.

Jarek

----- Original Message -----
From: "Chris" <[hidden email]>
To: "Francis Gingras" <[hidden email]>;
<[hidden email]>
Sent: Friday, April 07, 2006 9:29 PM
Subject: Re: [Nlog-list] logging exception details


> thanks for the quick reply.
> I tried that and it gave me all the info I wanted, but I would like to
> be able to write out the stack trace on multiple lines (like it does
> when you use the ToString() method).
> I have 2 log files for my app, a detailed error log and a trace log
> (which also logs very basic info on errors on a single line). I'm not
> trying to squeeze as much info on one line as possible with the error
> log, because generally I just scroll to the bottom to see the last
> exception.
>
> Does anyone have an example of how to use the exception layout
> renderer that I linked in my original post?
>
> Chris
>
> On 4/7/06, Francis Gingras <[hidden email]> wrote:
>> Chris,
>>
>> This is what I use:
>> <target name="error" type="File"
>> filename="${basedir}/../logs/${date:format=/yyyy-MM-dd/}log.txt"
>> layout="${longdate}|${level:uppercase=true}|${logger}|${callsite}|${message}
>> |${exception}|${stacktrace}" />
>>
>> Francis
>>
>>
>>
>> -------------------------------------------------------
>> This SF.Net email is sponsored by xPML, a groundbreaking scripting
>> language
>> that extends applications into web and mobile media. Attend the live
>> webcast
>> and join the prime developer group breaking into this new coding
>> territory!
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>> _______________________________________________
>> Nlog-list mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/nlog-list
>>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd_______________________________________________
> Nlog-list mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/nlog-list
>



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
NLog Blog