quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.36k stars 2.56k forks source link

Cannot change quarkus.log.category."WebApplicationException".level #41610

Closed AndreasPetersen closed 2 days ago

AndreasPetersen commented 3 days ago

Describe the bug

I have a REST server that throws an InternalServerErrorException.

According to the documentation:

You can change the log level of the thrown WebApplicationException exceptions by configuring the following property quarkus.log.category."WebApplicationException".level like so:

quarkus.log.category."WebApplicationException".level=DEBUG

However, when I set it to ERROR, no log is made.

Expected behavior

That an error log is made

Actual behavior

No log is made

How to Reproduce?

I have provided a reproducer here.

  1. Start the service
  2. Call the /hello endpoint
  3. Observe that there is no error log

If you change application.properties to:

#quarkus.log.category."WebApplicationException".level=ERROR
quarkus.log.level=DEBUG

note that the error is logged at debug level. If you change it to:

quarkus.log.category."WebApplicationException".level=ERROR
quarkus.log.level=DEBUG

then no error is logged.

Output of uname -a or ver

Linux BD-PF4TWGEK 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "21.0.3" 2024-04-16 LTS OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode, sharing)

Quarkus version or git rev

3.12.0

Build tool (ie. output of mvnw --version or gradlew --version)

------------------------------------------------------------ Gradle 8.8 ------------------------------------------------------------ Build time: 2024-05-31 21:46:56 UTC Revision: 4bd1b3d3fc3f31db5a26eecb416a165b8cc36082 Kotlin: 1.9.22 Groovy: 3.0.21 Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023 JVM: 21.0.3 (Eclipse Adoptium 21.0.3+9-LTS) OS: Linux 5.15.153.1-microsoft-standard-WSL2 amd64

Additional information

No response

quarkus-bot[bot] commented 3 days ago

/cc @geoand (kotlin)

geoand commented 3 days ago

Can you try:

quarkus.log.category."jakarta.ws.rs.WebApplicationException".level=DEBUG

please?

AndreasPetersen commented 3 days ago

Thanks for the quick reply @geoand !

I tried setting application.properties to:

quarkus.log.category."jakarta.ws.rs.WebApplicationException".level=ERROR

but no log appeared. Setting application.properties to:

quarkus.log.category."jakarta.ws.rs.WebApplicationException".level=ERROR
quarkus.log.level=DEBUG

at least retains the WebApplicationException at the DEBUG level:

2024-07-02 14:34:39,950 DEBUG [WebApplicationException] (executor-thread-1) Restarting handler chain for exception exception: jakarta.ws.rs.InternalServerErrorException: This isn't logged
    ...
2024-07-02 14:34:39,952 DEBUG [WebApplicationException] (executor-thread-1) Application failed the request: jakarta.ws.rs.InternalServerErrorException: This isn't logged
    ...

Oddly enough it's logged twice.

geoand commented 3 days ago

quarkus.log.category."jakarta.ws.rs.WebApplicationException".level=ERROR

We don't want ERROR, we want DEBUG :)

dmlloyd commented 3 days ago

Right, the log levels become increasingly restrictive. You don't choose ERROR because you want to see errors, for example. Instead, you choose a level based on the verbosity you want:

So, you can see that if a message (like this error that you want to see) is logged at DEBUG, then when you set the level to ERROR, you've turned it off.

AndreasPetersen commented 3 days ago

I set application.properties to:

quarkus.log.category."jakarta.ws.rs.WebApplicationException".level=DEBUG

but no log is made

geoand commented 3 days ago

If you attach a sample application, I can have a look and see if there is something we might be missing

AndreasPetersen commented 3 days ago

Right, the log levels become increasingly restrictive. You don't choose ERROR because you want to see errors, for example. Instead, you choose a level based on the verbosity you want:

  • OFF - nothing is logged
  • ERROR - only ERROR-level messages are logged
  • WARN - both ERROR- and WARN-level messages are logged
  • INFO - ERROR, WARN, and INFO-level messages are logged
  • DEBUG - ERROR, WARN, INFO, and DEBUG-level messages are logged
  • etc.

So, you can see that if a message (like this error that you want to see) is logged at DEBUG, then when you set the level to ERROR, you've turned it off.

Ah, okay, so setting

quarkus.log.category."WebApplicationException".level=DEBUG

as stated in the documentation does indeed provide the expected result where the error is logged:

2024-07-02 14:43:46,655 DEBUG [WebApplicationException] (executor-thread-1) Restarting handler chain for exception exception: jakarta.ws.rs.InternalServerErrorException: This isn't logged
    ...
2024-07-02 14:43:46,657 DEBUG [WebApplicationException] (executor-thread-1) Application failed the request: jakarta.ws.rs.InternalServerErrorException: This isn't logged
    ...

However, the error is logged twice. Should I open a separate issue for that, and close this issue?

AndreasPetersen commented 3 days ago

If you attach a sample application, I can have a look and see if there is something we might be missing

I provided a link to a reproducer in the bug description, but I'll add it here too :) https://github.com/AndreasPetersen/quarkus-webapplication-log

geoand commented 3 days ago

So quarkus.log.category."WebApplicationException".level=DEBUG works, but it does indeed log twice. I'll convert the first part to trace, as there is almost no reason to have that information.

AndreasPetersen commented 3 days ago

Thanks for the help @geoand and @dmlloyd !