Skip to content

Conversation

@dluc
Copy link
Collaborator

@dluc dluc commented Dec 2, 2025

Summary

Implements comprehensive logging infrastructure using Serilog (Feature #6):

  • LoggingConfig: Configurable log level, file output, JSON format, async mode
  • SerilogFactory: Creates Microsoft.Extensions.Logging.ILoggerFactory instances
  • LoggerExtensions: CallerMemberName-based LogMethodEntry/LogMethodExit helpers
  • ActivityEnricher: Adds correlation IDs (TraceId/SpanId) from System.Diagnostics.Activity
  • SensitiveDataScrubbingPolicy: Automatically redacts strings in Production environment
  • EnvironmentDetector: Environment-based security decisions
  • LoggingConstants: Centralized magic values for maintainability
  • TestLoggerFactory: XUnit test output integration

Features

  • Console output to stderr (Warning+ by default)
  • File logging with daily rotation, 100MB limit, 30 file retention
  • JSON format option for log aggregation systems
  • Async logging option for better service performance
  • Automatic sensitive data scrubbing in Production

Documentation

  • Added docs/CONFIGURATION.md with complete configuration reference
  • Updated configuration-example.json with logging section
  • Marked feature 00006 as DONE

Test Plan

  • 95 new tests covering all logging components
  • Test coverage: 84.83% (above 80% threshold)
  • All 637 tests pass (0 skipped)
  • format.sh passes
  • build.sh passes with 0 warnings, 0 errors
  • coverage.sh passes

Implement comprehensive logging infrastructure using Serilog:

- Add LoggingConfig for configurable log level, file output, JSON format
- Add SerilogFactory to create Microsoft.Extensions.Logging.ILoggerFactory
- Add LoggerExtensions with CallerMemberName-based method entry/exit logging
- Add ActivityEnricher for correlation IDs (TraceId/SpanId)
- Add SensitiveDataScrubbingPolicy that redacts strings in Production
- Add EnvironmentDetector for environment-based security decisions
- Add LoggingConstants with centralized magic values
- Integrate LoggingConfig into AppConfig
- Add TestLoggerFactory for XUnit test output visibility

Features:
- Console output to stderr (Warning+ by default)
- File logging with daily rotation, 100MB limit, 30 file retention
- JSON format option for log aggregation
- Async logging option for services
- Automatic sensitive data scrubbing in Production environment

Test coverage: 84.83% (95 new tests)
@dluc dluc requested a review from Copilot December 2, 2025 14:53
Wire Serilog logging to CLI commands:
- Add --log-file option to enable file logging from CLI
- Wire --verbosity to Serilog log levels (silent=Fatal, quiet=Warning, normal=Info, verbose=Debug)
- Inject ILoggerFactory via DI into all commands
- Update BaseCommand to accept ILoggerFactory
- Update all command constructors to pass logger factory
- Fix environment detector test isolation
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements comprehensive Serilog-based logging infrastructure for the application, enabling configurable logging to console (stderr) and files with automatic sensitive data scrubbing in Production environments.

Key Changes:

  • Added Serilog logging components: SerilogFactory, LoggingConfig, ActivityEnricher, SensitiveDataScrubbingPolicy, EnvironmentDetector, and LoggerExtensions
  • Integrated logging into CLI commands via dependency injection with ILoggerFactory parameter
  • Added CLI flags (--verbosity, --log-file) and configuration file support for logging settings

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Core/Logging/*.cs New logging infrastructure classes
src/Core/Config/AppConfig.cs Added Logging property for configuration
src/Main/CLI/CliApplicationBuilder.cs Integrated logger factory creation and DI registration
src/Main/CLI/Commands/*.cs Updated all commands to accept ILoggerFactory parameter
src/Main/CLI/GlobalOptions.cs Added log-file option and GetLogLevel() method
tests/Core.Tests/Logging/*.cs Comprehensive test coverage for logging components
tests/Main.Tests/**/*.cs Updated tests to pass NullLoggerFactory.Instance
**/Directory.Packages.props Added Serilog package dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add EmptyTraceId and EmptySpanId constants to LoggingConstants
- Use constants in ActivityEnricher instead of magic strings
- Fix ParseArgValue loop to check all arguments including last one
- Document ILoggerFactory disposal behavior in Build() remarks
@dluc dluc merged commit 0c05ff7 into microsoft:main Dec 2, 2025
3 checks passed
@dluc dluc deleted the logging122 branch December 2, 2025 15:06
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.

1 participant