I want to write a stack trace only when I have exceptions, currently I am doing it like this:
layout="${longdate}|${level}|${message} ${exception:format=tostring} | ${stacktrace}"
Therefore, I always get it in my log file.
EDIT:
I use this layout for all my logging, so when I don't have any exceptions, I also get a stack trace. But I need this only when I have some kind of exception.
when I have an exception, I have the following conclusion, and this is what I need
2011-07-01 22:59:02.3782|Debug|fffffffffffffffffffffffffffff System.Exception: Exception of type 'System.Exception' was thrown. | AppDomain.ExecuteAssembly => AppDomain._nExecuteAssembly => Program.Main
But without exception:
2011-07-01 22:57:26.7117|Trace|fffffffffffffffffffffffffffff | AppDomain.ExecuteAssembly => AppDomain._nExecuteAssembly => Program.Main
But I only want
2011-07-01 22:57:26.7117|Trace|fffffffffffffffffffffffffffff
Need ideas how to do this ...
Night walker
source share