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

Missing exception class name in 500 handling #301

Closed
cies opened this issue Dec 13, 2023 · 3 comments · Fixed by #303
Closed

Missing exception class name in 500 handling #301

cies opened this issue Dec 13, 2023 · 3 comments · Fixed by #303
Assignees
Milestone

Comments

@cies
Copy link
Member

cies commented Dec 13, 2023

I'm not sure where things changed, but I seem to remember that I could see the class (e::class.getSimpleName()) of an exception in the logs. Currently it is gone.

Therefor I want to change this line:

logger.error("Internal Server Error (500) for request {} {}", request.method, request.url, e);

into:

logger.error("Internal Server Error (500) for {} {} ({})", request.method, request.url, e::class.getSimpleName(), e);

In the following files:

  javanet/src/play/server/javanet/PlayHandler.java
  netty3/src/play/server/netty3/PlayHandler.java
  netty4/src/play/server/netty4/PlayHandler.java

Without objections I'll create a PR. Suggestions welcome, as always, on how to make it even better.

@cies cies self-assigned this Dec 13, 2023
@cies
Copy link
Member Author

cies commented Dec 13, 2023

Maybe I'm mistaken, and was the exception class name never printed to the logs, as in Play1 I cannot find it:

https://github.com/playframework/play1/blob/f832ef82093fe3e18ddb99b9294ce7a5956080a7/framework/src/play/server/PlayHandler.java#L795

Or maybe it was part of the stacktrace in the past.

@xabolcs
Copy link
Collaborator

xabolcs commented Dec 14, 2023

Would you mind showing a few log line with and without the requested change as an example?

Maybe I'm mistaken, and was the exception class name never printed to the logs, as in Play1 I cannot find it.
Or maybe it was part of the stacktrace in the past.

Are you talking about PR #208?

@cies
Copy link
Member Author

cies commented Dec 15, 2023

Would you mind showing a few log line with and without the requested change as an example?

Here you go, straight from our logs (with some text replaced to not share too much internals):

Dec 13 20:41:34 netty3.PlayHandler Internal Server Error (500) for request POST /some/path
Dec 13 20:41:34 SQL [insert into `SomeTable` (`createdAt`, `modifiedAt`, `organization_id`, `status`, `paymentType`, `emailAddress`) values (?, ?, ?, ?, ?, ?)]; Deadlock found when trying to get lock; try restarting transaction
Dec 13 20:41:34 at org.jooq_3.18.6.MYSQL.debug(Unknown Source)
Dec 13 20:41:34 at org.jooq.impl.Tools.translate(Tools.java:3470)
Dec 13 20:41:34 at org.jooq.impl.Tools.translate(Tools.java:3458)
Dec 13 20:41:34 at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:801)
Dec 13 20:41:34 at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:360)
Dec 13 20:41:34 at org.jooq.impl.TableRecordImpl.storeInsert0(TableRecordImpl.java:197)
Dec 13 20:41:34 at org.jooq.impl.TableRecordImpl.lambda$storeInsert$0(TableRecordImpl.java:163)
Dec 13 20:41:34 at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:144)
Dec 13 20:41:34 at org.jooq.impl.TableRecordImpl.storeInsert(TableRecordImpl.java:162)
Dec 13 20:41:34 at org.jooq.impl.UpdatableRecordImpl.store0(UpdatableRecordImpl.java:222)
Dec 13 20:41:34 at org.jooq.impl.UpdatableRecordImpl.lambda$store$0(UpdatableRecordImpl.java:149)
Dec 13 20:41:34 at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:144)
Dec 13 20:41:34 at org.jooq.impl.UpdatableRecordImpl.store(UpdatableRecordImpl.java:148)
Dec 13 20:41:34 at org.jooq.impl.UpdatableRecordImpl.store(UpdatableRecordImpl.java:140)
...

Say I want to catch this exception, how do I find the actual class name of the exception? Sure, I'll find it, but it would we nice if it was in the logs.

Maybe I'm mistaken, and was the exception class name never printed to the logs, as in Play1 I cannot find it. Or maybe it was part of the stacktrace in the past.

Are you talking about PR #208?

No. We recently moved all code to Kotlin. Since I seem to remember that we used to be able to see the exception's class name in the logs with every exception that bubbles up to become a 500 error, I thought that maybe stacktraces contain slightly less info since we move to Kotlin. Probably not true. Just a thought. Maybe I'm mistaken and we never were able to see the class name of the exception in the logs on 500s.

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 a pull request may close this issue.

3 participants