Skip to content

Conversation

@justindbaur
Copy link
Member

@justindbaur justindbaur commented Oct 29, 2025

🎟️ Tracking

📔 Objective

Removes deprecated logging methods in accordance with https://contributing.bitwarden.com/architecture/adr/standard-output-logging and these methods having been deprecated for 3 months https://bitwarden.com/help/releasenotes/#2025-7-3

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@justindbaur justindbaur marked this pull request as ready for review October 29, 2025 17:30
@justindbaur justindbaur requested review from a team as code owners October 29, 2025 17:30
@claude
Copy link

claude bot commented Oct 29, 2025

Claude finished @justindbaur's task —— View job


Code Review Complete

Summary of Changes

This PR successfully removes deprecated logging methods that have been deprecated for 3+ months per the release notes. The changes align with ADR-0021 (Standard Output Logging) and eliminate the custom Sentry and Syslog logging integrations in favor of standard output logging with Serilog.Extensions.Logging.File.

Key Changes:

  • Removed ~683 lines of deprecated code across 44 files
  • Deleted 12 log level settings classes and interfaces
  • Removed Sentry and Syslog logging infrastructure
  • Simplified LoggerFactoryExtensions.cs from 165 lines to 78 lines
  • Removed 3 NuGet package dependencies (Serilog.AspNetCore, Sentry.Serilog, Serilog.Sinks.SyslogMessages)
  • Cleaned up Program.cs files across all services (Api, Identity, Admin, Events, Notifications, Billing, Scim, Sso, etc.)
  • Updated tests to reflect simplified logging configuration

Critical Issues Found

None.


Suggested Improvements

1. Empty XML Documentation Comments

Location: src/Core/Utilities/LoggerFactoryExtensions.cs:10-14

/// <summary>
/// 
/// </summary>
/// <param name="hostBuilder"></param>
/// <returns></returns>
public static IHostBuilder AddSerilogFileLogging(this IHostBuilder hostBuilder)

The XML documentation for AddSerilogFileLogging is empty. Consider adding meaningful documentation:

Suggested documentation
/// <summary>
/// Configures file-based logging using Serilog for production environments.
/// Supports both legacy GlobalSettings configuration and new Logging:PathFormat configuration.
/// </summary>
/// <param name="hostBuilder">The host builder to configure.</param>
/// <returns>The configured host builder for method chaining.</returns>

Severity: Minor - The method name is self-documenting, but proper XML docs would be more consistent with project standards.


2. Consider Adding Obsolete Warnings to Remaining NuGet Packages in Renovate Config

Location: .github/renovate.json5:89

The PR removes Sentry.Serilog, Serilog.AspNetCore, and Serilog.Sinks.SyslogMessages from the Renovate allowlist, but Serilog.Extensions.Logging.File remains. This is correct since file logging is still supported for legacy configurations. However, consider whether this package should eventually be phased out as well (though this may be out of scope for this PR).

Severity: Informational - This is forward-looking and not an issue with the current changes.


3. Missing Unit Test for Legacy Configuration Without LogDirectory

Location: test/Core.Test/Utilities/LoggerFactoryExtensionsTests.cs

The updated tests cover:

  • Development environment (no providers added)
  • Production environment (provider added)
  • Legacy file logging with LogDirectory set
  • New file logging with Logging:PathFormat

However, there's no explicit test for the early return path when legacy configuration has no LogDirectory set (line 35 in LoggerFactoryExtensions.cs). While this is a minor edge case, a test would ensure the early return works as expected.

Suggested test case
[Fact]
public void AddSerilog_LegacyConfig_NoLogDirectory_AddsNoProviders()
{
    var providers = GetProviders(new Dictionary<string, string?>
    {
        { "GlobalSettings:ProjectName", "Test" },
        { "GlobalSettings:LogDirectory", "" },
    });

    Assert.Empty(providers);
}

Severity: Minor - The code path is simple and unlikely to break, but test coverage would be more complete.


Good Practices Observed

  • Comprehensive cleanup: All deprecated code paths removed consistently across all services
  • Backward compatibility maintained: Legacy file logging configuration still supported through LegacyFileLoggingOptions
  • Dependency cleanup: Removed unused NuGet packages (Sentry.Serilog, Serilog.AspNetCore, Serilog.Sinks.SyslogMessages)
  • Test maintenance: Updated tests to reflect new simplified behavior
  • Code simplification: LoggerFactoryExtensions.cs reduced from 165 to 78 lines while maintaining functionality
  • Consistent application: Changes applied uniformly across all 10+ services (Api, Identity, Admin, Events, Notifications, Billing, Scim, Sso, Icons, EventsProcessor)

Action Items for Author

  1. Optional: Add XML documentation to AddSerilogFileLogging method (see improvement Identity Server  #1)
  2. Optional: Consider adding test case for empty LogDirectory scenario (see improvement .NET Core Runtime #3)

Conclusion

This is a well-executed cleanup PR that successfully removes deprecated logging infrastructure while maintaining backward compatibility for legacy configurations. The changes are consistent, comprehensive, and align with the documented ADR. The simplified code is easier to understand and maintain.

Recommendation:Approve - The PR is ready to merge. The suggested improvements are minor and optional.


Todo List

  • Gather context and read key changed files
  • Review LoggerFactoryExtensions.cs changes (core logging logic)
  • Review GlobalSettings.cs changes
  • Review Program.cs changes across services
  • Review test changes
  • Compile comprehensive review feedback
  • Post final review

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 66.00000% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.93%. Comparing base (ca0d5bf) to head (1931572).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/Core/Utilities/LoggerFactoryExtensions.cs 71.79% 8 Missing and 3 partials ⚠️
bitwarden_license/src/Sso/Program.cs 0.00% 1 Missing ⚠️
src/Admin/Program.cs 0.00% 1 Missing ⚠️
src/Billing/Program.cs 0.00% 1 Missing ⚠️
src/EventsProcessor/Program.cs 0.00% 1 Missing ⚠️
src/Icons/Program.cs 0.00% 1 Missing ⚠️
src/Notifications/Program.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6516      +/-   ##
==========================================
+ Coverage   51.86%   51.93%   +0.06%     
==========================================
  Files        1902     1891      -11     
  Lines       84057    83808     -249     
  Branches     7501     7469      -32     
==========================================
- Hits        43598    43524      -74     
+ Misses      38765    38593     -172     
+ Partials     1694     1691       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

Logo
Checkmarx One – Scan Summary & Detailsa67c685b-55e9-4a65-9852-90ddf2a285e6

Great job! No new security vulnerabilities introduced in this pull request

{
{ "GlobalSettings:ProjectName", "Test" },
{ "GlobalSetting:LogDirectoryByProject", "true" },
{ "GlobalSettings:LogDirectoryByProject", "true" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Nice catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants