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

Logging with brackets (lazy) eats the eventual exceptions #260

Closed
petrum opened this issue Nov 4, 2022 · 5 comments
Closed

Logging with brackets (lazy) eats the eventual exceptions #260

petrum opened this issue Nov 4, 2022 · 5 comments

Comments

@petrum
Copy link

petrum commented Nov 4, 2022

For example the following simple code is supposed to fail:

fun main(args: Array<String>) {
    log.info{"This cannot be converted to int!".toInt()}
    log.info("I'm not supposed to see this line!")

However it does not fail:

2022-11-04 13:40:53:802 -0400 [main] INFO Main - Log message invocation failed: java.lang.NumberFormatException: For input string: "This cannot be converted to int!"
2022-11-04 13:40:53:804 -0400 [main] INFO Main - I'm not supposed to see this line!

This is unexpected: logging is not supposed to catch any user exceptions, it should not affect the intended path in any way.

Thanks,
Petru

@github-actions
Copy link

github-actions bot commented Nov 4, 2022

Thank you for reporting an issue. See the wiki for documentation and slack for questions.

@oshai
Copy link
Owner

oshai commented Nov 4, 2022

This was introduced in #22 and later discussed in #160. Id you start the jvm with -Dkotlin-logging.throwOnMessageError it will throw the exception instead of logging it.

@petrum
Copy link
Author

petrum commented Nov 4, 2022 via email

@oshai
Copy link
Owner

oshai commented Nov 4, 2022

You can see in issue 22 why we made that the default: #22 (comment)

Mostly because that's how other framework works.

@petrum
Copy link
Author

petrum commented Nov 4, 2022 via email

@oshai oshai closed this as completed Feb 13, 2023
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

No branches or pull requests

2 participants