Skip to content

Call LogException(ex) rather than LogError(ex.ToString()) #176

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

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

Conversation

Xpl0itR
Copy link

@Xpl0itR Xpl0itR commented Mar 26, 2025

This will allow us to do something like ConsoleApp.LogException = ex => logger.LogCritical(ex, "Unhandled exception.");
It is better to allow the logger to format the exception.

@neuecc
Copy link
Member

neuecc commented Jun 23, 2025

ConsoleApp.Log and LogError are just simple or system-level logging methods, so if you want to use logging actively, I think you should inject your own logger and use that instead.

@Xpl0itR
Copy link
Author

Xpl0itR commented Jun 26, 2025

@neuecc hi, of course in my handlers I inject ILogger properly, the main motivation behind this PR is here, when an exception is not caught in a handler and the exception is not ValidationException or ArgumentParseFailedException, it would be good to pass the exception to the logger.

@neuecc
Copy link
Member

neuecc commented Jun 27, 2025

If you want to customize it that much, I think that part can be handled with filters, so we might not need to include it.

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.

2 participants