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

[CORELIB-75] DI injected logger #757

Open
wants to merge 4 commits into
base: v9.0-preview
Choose a base branch
from

Conversation

wojtek2288
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Feb 7, 2025

test: Run #2123

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
747 746 0 1 0 0 0 272ms

🎉 All tests passed!

Github Test Reporter

🔄 This comment has been updated

@jakubfijalkowski
Copy link
Member

Let's also discuss this internally in a wider group.

@@ -40,7 +45,7 @@ public async Task InvokeAsync(HttpContext httpContext)
activity?.SetTag("error.code", ex.ErrorCode);

var result = WrapInCommandResult(ex);
logger.Warning("Command {@Command} is not valid with result {@Result}", cqrsPayload.Payload, result);
logger.LogWarning("Command {@Command} is not valid with result {@Result}", cqrsPayload.Payload, result);
Copy link
Member

Choose a reason for hiding this comment

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

Is {@Command} syntax an extensions logging standard? I've always though it was a serilog goodie (chat gpt confirms it). So, I sb ever want's to change logger implementation I guess it'd break.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, right in some loggers ToString() might be called here. We probably need to change @Command to Command and pass JsonSerializer.Serialize(cqrsPayload.Payload) as an argument to make it work with any logger.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is a good approach. It will break the "sanitizer" logic that we have and we need to support that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then I'm not sure if we can do anything about it right now other then making sanitization logger agnostic.

Copy link
Contributor

Choose a reason for hiding this comment

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

So if we'd abstract this way from Serilog we'd lose this functionality, which would be sad. Is there a way to not abstract the Serilog, and still use the DI based loggers? If so, I'd say let's go with it (unless it isn't too ugly), and in the other case I'd stick with what we've done until now.

Copy link
Member

Choose a reason for hiding this comment

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

If serilog does not provide anything out of the box, I think we can safely register Serilog.ILogger<T> as open generic and link it with DI

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.

4 participants