Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

[ADMINAPI-1322] Double logging in the RequestLoggingMiddleware#376

Merged
DavidJGapCR merged 2 commits intomainfrom
ADMINAPI-1322
Nov 10, 2025
Merged

[ADMINAPI-1322] Double logging in the RequestLoggingMiddleware#376
DavidJGapCR merged 2 commits intomainfrom
ADMINAPI-1322

Conversation

@jagudelo-gap
Copy link

This pull request refactors how logging is configured and initialized in the application, specifically focusing on log4net setup. The main improvement is the encapsulation of logging initialization logic into a dedicated extension method, which simplifies and standardizes logging configuration throughout the application. Additionally, some redundant code is removed to streamline the startup process.

Logging configuration refactor:

  • Moved log4net initialization logic from Program.cs into a new extension method AddLoggingServices in WebApplicationBuilderExtensions.cs, improving code organization and reusability. [1] [2]
  • The new AddLoggingServices method clears all default logging providers, initializes log4net early based on configuration, and adds log4net as the logging provider, ensuring consistent logging setup.

Code cleanup:

  • Removed the previous log4net configuration code from the AddServices method in WebApplicationBuilderExtensions.cs, preventing duplicate or conflicting logging setups.

Dependency updates:

  • Added necessary log4net and log4net.Config using statements to support the new logging initialization logic.

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

Test Results

338 tests   337 ✅  15s ⏱️
  4 suites    1 💤
  4 files      0 ❌

Results for commit a13213c.

♻️ This comment has been updated with latest results.

@jagudelo-gap jagudelo-gap requested a review from Copilot November 10, 2025 14:39
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

This PR refactors logging initialization by extracting inline log4net configuration code from Program.cs into a dedicated AddLoggingServices extension method in WebApplicationBuilderExtensions.cs. This improves code organization and maintainability by consolidating logging setup logic.

Key changes:

  • Extracted log4net initialization code from Program.cs into new AddLoggingServices extension method
  • Added clearing of default logging providers to prevent duplicate logging
  • Consolidated all logging configuration in one location for better maintainability

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Application/EdFi.Ods.AdminApi/Program.cs Replaced inline log4net initialization with call to AddLoggingServices() extension method
Application/EdFi.Ods.AdminApi/Infrastructure/WebApplicationBuilderExtensions.cs Added new AddLoggingServices method containing log4net initialization logic, including clearing default providers and configuring log4net

@DavidJGapCR DavidJGapCR merged commit 6443d40 into main Nov 10, 2025
28 of 30 checks passed
@DavidJGapCR DavidJGapCR deleted the ADMINAPI-1322 branch November 10, 2025 21:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants