[log4net-bridge] limit chances of duplicated logs export both bridges are enabled #3948
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why && What
In some cases,
log4net
might be used directly to log something (e.g beforeILogger
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
andlog4net
bridges), stop sending logs (and log warning) throughlog4net
bridge whenILogger
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 beforeILogger
integration is initialized will be exported throughlog4net
bridge.The limitation of implemented approach is that whatever is logged directly using
log4net
API afterILogger
integration is initialized won't be exported bylog4net
bridge.Tests
Existing tests, updated in this PR.
Checklist
- [ ]CHANGELOG.md
is updated.- [ ] Documentation is updated.- [ ] New features are covered by tests.