Reputation: 23
When using a MailTarget
with a custom LayoutRenderer
, I can see that LogEventInfo.StackTrace
contains data which can then be included in the rendered response.
However, replacing the MailTarget
with WebServiceTarget
and using the same custom LayoutRenderer
LogEventInfo.StackTrace
now returns null
Both targets are "stock" NLog implementations, are being invoked from the same code using the same LayoutRenderer
Has anyone else experienced this same issue? Is there some limitation of WebServiceTarget
that prevents stack traces being captured?
Solution, based on Rolf's suggestion below:
public sealed class MyLayoutRenderer : LayoutRenderer, IUsesStackTrace
{
public StackTraceUsage StackTraceUsage => StackTraceUsage.Max;
....
}
Upvotes: 2
Views: 131
Reputation: 19867
NLog only captures and provides StackTrace for a target, if you are using a layoutrenderer like Ex. ${callsite}
.
If you have a custom layout-renderer, then you can inherit from NLog.Internal.IUsesStackTrace
(And return StackTraceUsage.Max
)
Upvotes: 2