0

I am using loggly with NLog in C#.

When I use, for example, the following code.

protected static readonly NLog.Logger _log = NLog.LogManager.GetCurrentClassLogger();                      

try
{
    ...
}
catch (Exception ex)
{
    _log.Error(ex, "UpdateBrokerData {Account}", accountBalanceDto.Account);
}

The exception message is displayed but none of the inner exceptions.

Is there a way to get this to happen (perhaps with a setting in the NLog.config?

Here is the loggly part of my NLog.config file.

<target name="Loggly" xsi: type="Loggly">
  <layout xsi:type="JsonLayout" includeAllProperties="true" excludeProperties="">
    <attribute name="environment" layout="${environment:ASPNETCORE_ENVIRONMENT}" />
    <attribute name="time" layout="${longdate}" />
    <attribute name="level" layout="${level:upperCase=true}"/>
    <attribute name="message" layout="${message}" />
  </layout>
</target>
Useme Alehosaini
  • 2,998
  • 6
  • 18
  • 26
Brian Rice
  • 3,107
  • 1
  • 35
  • 53
  • 1
    Does this answer your question? [NLog Inner Exception Loggin](https://stackoverflow.com/questions/44287491/nlog-inner-exception-loggin) – Oleg Kyrylchuk Apr 16 '20 at 21:23
  • Maybe... but the loggly stuff seems separate... but I'll try it and see if it actually does change things. – Brian Rice Apr 16 '20 at 21:58
  • I don't think so... because in that answer it has type file and filename... which wouldn't apply for loggly... my question is how to get this same functionality with NLog and loggly. – Brian Rice Apr 16 '20 at 22:14
  • Looking at the code of a random NLog Loggly Target. Then it looks like the Exception-object is just added to the Data-collection and is then JsonSerialized. https://github.com/neutmute/nlog-targets-loggly/blob/966c4b11f5c198dfd2a0b43434b19932dda659f6/src/NLog.Targets.Loggly/LogglyTarget.cs#L275 and https://github.com/neutmute/loggly-csharp/blob/a7518a2ed734b2f820b47340059cf1f1dbebaf30/source/Loggly/LogglyClient.cs#L74 – Rolf Kristensen Apr 17 '20 at 05:15

0 Answers0