Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[log4net-bridge] limit chances of duplicated logs export both bridges are enabled #3948

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lachmatt
Copy link
Contributor

@lachmatt lachmatt commented Jan 16, 2025

Why && What

In some cases, log4net might be used directly to log something (e.g before ILogger logging pipeline is built, similar example from serilog's documentation) before being used as a logging provider. If both logging bridges would be enabled in such case, it could result in duplicated logs export.

In order to limit chances of duplicated logs export (through both ILogger and log4net bridges), stop sending logs (and log warning) through log4net bridge when ILogger bridge usage is detected.

Documentation of the log4net bridge was also updated to discourage the enablement of both log bridges at the same time.

With current implementation, whatever is logged using log4net API before ILogger integration is initialized will be exported through log4net bridge.
The limitation of implemented approach is that whatever is logged directly using log4net API after ILogger integration is initialized won't be exported by log4net bridge.

Tests

Existing tests, updated in this PR.

Checklist

- [ ] CHANGELOG.md is updated.
- [ ] Documentation is updated.
- [ ] New features are covered by tests.

@lachmatt lachmatt requested a review from a team as a code owner January 16, 2025 11:00
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