Skip to content

Replace logging own implementation with withMicrosoft Extensions Logging#4806

Merged
arturcic merged 31 commits intoGitTools:next/v7from
arturcic:feature/replace-logging-with-ms-extensions
Feb 3, 2026
Merged

Replace logging own implementation with withMicrosoft Extensions Logging#4806
arturcic merged 31 commits intoGitTools:next/v7from
arturcic:feature/replace-logging-with-ms-extensions

Conversation

@arturcic
Copy link
Copy Markdown
Member

@arturcic arturcic commented Jan 28, 2026

This pull request introduces a major overhaul of the logging system, replacing the custom ILog abstraction with the industry-standard Microsoft.Extensions.Logging (M.E.L.) infrastructure, using Serilog as the underlying provider. It removes the legacy logging types, updates dependency injection and usage throughout the codebase, and ensures logging configuration is handled consistently at application startup. Several test and helper classes have also been updated or removed to align with the new logging approach.

Logging System Replacement and Refactoring:

  • The custom ILog logging system and related types (ILog, ILogAppender, LogLevel, etc.) have been removed and replaced with Microsoft.Extensions.Logging and Serilog. Consumers now use ILogger<T> and related abstractions. [1] [2] F61fee1bL18R18, [3]
  • Logging configuration is now handled centrally at application startup via the new LoggingEnricher.Configure method, which sets up log file paths, verbosity, and console output based on command-line arguments. [1] [2] [3]
  • All usages of the old logging system in classes such as GitVersionApp, GitVersionExecutor, and test fixtures have been updated to use dependency-injected ILogger<T> instances. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Dependency and Project File Updates:

  • Added Microsoft.Extensions.Logging, Microsoft.Extensions.Logging.Abstractions, and Serilog-related packages to the project dependencies, and updated using statements and project references accordingly. [1] F61fee1bL18R18, [2] [3]

Test and Helper Cleanup:

  • Removed or replaced test helpers and fixtures that relied on the old logging abstractions, such as TestLogAppender, and updated test setup to use the new logging system. [1] [2] [3] [4]

Documentation:

  • Added a section to BREAKING_CHANGES.md detailing the migration steps and impact of the logging system replacement for custom integrations and extensions.

Minor Test Adjustments:

  • Updated test assertions and logging output checks to align with the new logging format and behavior.

These changes modernize the logging infrastructure, improve extensibility and maintainability, and bring the codebase in line with .NET ecosystem best practices.

@arturcic arturcic force-pushed the feature/replace-logging-with-ms-extensions branch from 746b685 to ddc30d4 Compare January 28, 2026 21:29
@arturcic arturcic force-pushed the feature/replace-logging-with-ms-extensions branch from 08e6a50 to 571466a Compare January 29, 2026 01:18
@arturcic arturcic changed the title Feature/replace logging with ms extensions Replace logging own implementation with with ms extensions Jan 29, 2026
@arturcic arturcic force-pushed the feature/replace-logging-with-ms-extensions branch 12 times, most recently from b7c2089 to 950d0d1 Compare January 30, 2026 15:10
@arturcic arturcic force-pushed the feature/replace-logging-with-ms-extensions branch 8 times, most recently from fde552d to 85790ef Compare February 2, 2026 13:34
Move IConsole interface and ConsoleAdapter implementation from
GitVersion.Logging namespace to the GitVersion namespace under
a new Console folder for better organization.
Add new logging enrichers and extensions for Serilog integration:
- LoggingEnricher: controls log level and file output path dynamically
- SensitiveDataEnricher: masks passwords in URLs using GeneratedRegex
- LoggerExtensions: provides BeginTimedOperation and LogSeparator methods

The SensitiveDataEnricher replaces the external Serilog.Enrichers.Sensitive
package to avoid assembly loading issues in MSBuild task context.
Add TestLogger<T>, TestLoggerFactory, and FactoryLogger<T> to support
capturing log messages in unit tests when using ILogger<T> instead
of the legacy ILog interface.
Add Serilog packages to support the new logging system:
- Serilog
- Serilog.Extensions.Logging
- Serilog.Sinks.Console
- Serilog.Sinks.File
- Serilog.Sinks.Map
- Microsoft.Extensions.Logging.Abstractions

Remove Serilog.Enrichers.Sensitive which caused MSBuild assembly
loading issues.
Add AddGitVersionLogging extension method to configure Serilog with:
- Console output (conditionally enabled)
- File output (dynamically configured via LoggingEnricher)
- SensitiveDataEnricher for URL password masking
- LoggingEnricher for verbosity control

Update GitVersionCommonModule to use the new logging system.
arturcic added a commit that referenced this pull request Feb 8, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Feb 8, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Feb 14, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Feb 16, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Feb 16, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Feb 16, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Mar 1, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Mar 1, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Mar 2, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Mar 2, 2026
arturcic added a commit that referenced this pull request Mar 2, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Mar 2, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Mar 2, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Mar 2, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Mar 3, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
@arturcic arturcic added this to the 7.x milestone Mar 3, 2026
arturcic added a commit that referenced this pull request Mar 3, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Mar 3, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Mar 4, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Mar 5, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Mar 6, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Mar 7, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Mar 10, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Mar 12, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Mar 12, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Mar 12, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Mar 12, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit that referenced this pull request Mar 12, 2026
…s-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
arturcic added a commit to arturcic/GitVersion that referenced this pull request Mar 14, 2026
…g-with-ms-extensions

Replace logging own implementation with withMicrosoft Extensions Logging
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.

[ISSUE]: Replace the custom ILog implementation with the standard Microsoft.Extensions.Logging.Abstractions with Serilog

2 participants