Skip to content

Conversation

@Flash0ver
Copy link
Member

@Flash0ver Flash0ver commented May 16, 2025

Initial implementation for Sentry.Extensions.Logging
Initial integrations for

  • Sentry.AspNetCore
  • Sentry.Maui

Logs: https://develop.sentry.dev/sdk/telemetry/logs/

fixes #4351

Added

  • Log implementation via ILogger
    • Sentry.Extensions.Logging.SentryStructuredLogger
  • Log integrations via ILoggerProvider for
    • Sentry.Extensions.Logging
    • Sentry.AspNetCore
    • Sentry.Maui
  • Option (and BindableOption)
    • LogLevel MinimumLogLevel
  • Benchmark for new ILogger
  • A Polyfill method that is not provided by the Polyfill package

Changed

  • SentryLog.Parameters, used via SentryOptions.SetBeforeSendLog callback
    • -public ImmutableArray<object> Parameters { get; init; }
      +public ImmutableArray<KeyValuePair<string, object>> Parameters { get; init; }
    • where the SentrySdk.Logger APIs keep setting the index-based parameter names
    • and the new Log-Integration sets the named parameter names from Microsoft.Extensions.Logging

Fixed

  • Log timestamp now sent as double rather than int to include milliseconds

Testing

Apart from unit testing, manually tested via Samples (Console, ASP.NET Core, and .NET MAUI),
via different means of logging:

// ILogger Extension Methods
logger.LogInformation(new EventId(1, "EventName"), "String={Name}, Number={Number}, Boolean={Boolean}", "Hello", 2025, true);

// LoggerMessage.Define
internal static readonly Action<ILogger, string, int, bool, Exception> Hello = LoggerMessage.Define<string, int, bool>(
  LogLevel.Information, new EventId(1, "EventName"), "String={Name}, Number={Number}, Boolean={Boolean}");

// Source-Generated Logging
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "String={Name}, Number={Number}, Boolean={Boolean}")]
internal static partial void Hello(this ILogger logger, string name, int number, bool boolean);
image

Flash0ver and others added 30 commits April 30, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Experimental Sentry Logs not working

5 participants