Skip to content

Commit d02d1d8

Browse files
author
Josh DeGraw
committed
Updated exception info being passed as breadcrumb data
1 parent fe412a3 commit d02d1d8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Sentry.NLog/SentryTarget.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,20 @@ protected override void Write(LogEventInfo logEvent)
179179
// Whether or not it was sent as event, add breadcrumb so the next event includes it
180180
if (logEvent.Level >= Options.MinimumBreadcrumbLevel)
181181
{
182+
var message = string.IsNullOrWhiteSpace(formatted)
183+
? exception?.Message ?? string.Empty
184+
: formatted;
185+
182186
IDictionary<string, string> data = null;
183187

184188
// If this is true, an exception is being logged with no custom message
185-
if (exception != null && !string.IsNullOrWhiteSpace(formatted) && logEvent.Message != "{0}")
189+
if (exception != null && !message.StartsWith(exception.Message))
186190
{
187191
// Exception.Message won't be used as Breadcrumb message Avoid losing it by adding as data:
188192
data = new Dictionary<string, string>
189193
{
190-
{ "exception_message", exception.Message }
194+
{ "exception_data", exception.GetType().ToString() },
195+
{ "exception_message", exception.Message },
191196
};
192197
}
193198

@@ -201,10 +206,6 @@ protected override void Write(LogEventInfo logEvent)
201206
data.AddRange(contextProps.MapValues(a => a.ToString()));
202207
}
203208

204-
var message = string.IsNullOrWhiteSpace(formatted)
205-
? exception?.Message
206-
: formatted;
207-
208209
hub.AddBreadcrumb(
209210
_clock,
210211
message,

0 commit comments

Comments
 (0)