/// <summary> /// Append log. /// </summary> /// <param name="loggingEvent">The event.</param> protected override void Append(LoggingEvent loggingEvent) { if (loggingEvent == null) { return; } if (!Hub.IsEnabled && _sdkHandle == null) { if (Dsn == null) { return; } lock (_initSync) { if (_sdkHandle == null) { _sdkHandle = _initAction(Dsn); Debug.Assert(_sdkHandle != null); } } } // Either log a BreadCrumb or an Event if (MinimumBreadcrumbLevel < loggingEvent.Level) { var exception = loggingEvent.ExceptionObject ?? loggingEvent.MessageObject as Exception; var evt = new SentryEvent(exception) { Sdk = { Name = Constants.SdkName, Version = NameAndVersion.Version }, Logger = loggingEvent.LoggerName, Level = loggingEvent.ToSentryLevel() }; evt.Sdk.AddPackage(ProtocolPackageName, NameAndVersion.Version ?? string.Empty); if (!string.IsNullOrWhiteSpace(loggingEvent.RenderedMessage)) { evt.Message = loggingEvent.RenderedMessage; } evt.SetExtras(GetLoggingEventProperties(loggingEvent)); if (SendIdentity && !string.IsNullOrEmpty(loggingEvent.Identity)) { evt.User = new User { Id = loggingEvent.Identity }; } if (!string.IsNullOrWhiteSpace(Environment)) { evt.Environment = Environment; } Hub.CaptureEvent(evt); } else { string message = !string.IsNullOrWhiteSpace(loggingEvent.RenderedMessage) ? loggingEvent.RenderedMessage : ""; string type = ""; string category = loggingEvent.LoggerName; BreadcrumbLevel level = loggingEvent.ToBreadcrumbLevel(); IDictionary <string, string> data = GetLoggingEventProperties(loggingEvent).ToDictionary(x => x.Key, x => x.Value.ToString()); Hub.AddBreadcrumb(message, category, type, data, level); } }