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

quarkus-logging-json - excluding/overriding keys not working #36133

Closed
GinaGeorgescul opened this issue Sep 25, 2023 · 3 comments
Closed

quarkus-logging-json - excluding/overriding keys not working #36133

GinaGeorgescul opened this issue Sep 25, 2023 · 3 comments
Labels
area/logging kind/bug Something isn't working

Comments

@GinaGeorgescul
Copy link

Describe the bug

I am using the quarkus-logging-json library (Quarkus version 2.16.1) for the JSON Logging format.
According to the documentation (https://quarkus.io/version/2.16/guides/logging#quarkus-logging-json_quarkus.log.file.json.key-overrides), I am using quarkus.log.console.json.excluded-keys and quarkus.log.console.json.key-overrides in order to exclude and override some keys:
quarkus.log.console.json.excluded-keys=["loggerClassName", "sequence", "hostName", "ndc", "processId", "processName", "threadId"] quarkus.log.console.json.key-overrides="threadName=thread.name, level=log.level, loggerName=logger.name"

When setting the property for overriding I get:
Failed to start application (with profile [dev]): java.lang.IllegalArgumentException: No enum constant org.jboss.logmanager.formatters.StructuredFormatter.Key."THREADNAME

If I delete it and only try to exclude the keys, none of them is excluded.

Expected behavior

quarkus.log.console.json.excluded-keys=["loggerClassName", "sequence", "hostName", "ndc", "processId", "processName", "threadId"] should exclude the keys from the list.
quarkus.log.console.json.key-overrides="threadName=thread.name, level=log.level, loggerName=logger.name, mdc.traceId=traceId" should override the mentioned keys with the defined replacement names.

Actual behavior

quarkus.log.console.json.key-overrides="threadName=thread.name, level=log.level, loggerName=logger.name, mdc.traceId=traceId" fails with Failed to start application (with profile [dev]): java.lang.IllegalArgumentException: No enum constant org.jboss.logmanager.formatters.StructuredFormatter.Key."THREADNAME

quarkus.log.console.json.excluded-keys=["loggerClassName", "sequence", "hostName", "ndc", "processId", "processName", "threadId"] does not exclude any of the keys.

How to Reproduce?

  1. Add quarkus-logging-json dependency.
  2. Specify override and exclusion properties. Eg:
    quarkus.log.console.json.excluded-keys=["loggerClassName", "sequence", "hostName", "ndc", "processId", "processName", "threadId"] quarkus.log.console.json.key-overrides="threadName=thread.name, level=log.level, loggerName=logger.name"
  3. Run the application:
    quarkus dev

Output of uname -a or ver

Linux devbox 5.4.0-150-generic #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.19" 2023-04-18 OpenJDK Runtime Environment (build 11.0.19+7-post-Ubuntu-0ubuntu118.04.1) OpenJDK 64-Bit Server VM (build 11.0.19+7-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.1

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

Apache Maven 3.8.6

Additional information

No response

@GinaGeorgescul GinaGeorgescul added the kind/bug Something isn't working label Sep 25, 2023
@GinaGeorgescul GinaGeorgescul changed the title Hello, quarkus-logging-json - excluding/overriding keys not working Sep 25, 2023
@ozangunalp
Copy link
Contributor

Did you try omitting the quotes and spaces? Like :

quarkus.log.console.json.excluded-keys=loggerClassName,sequence,hostName,ndc,processId,processName,threadId
quarkus.log.console.json.key-overrides=threadName=thread.name,level=log.level,loggerName=logger.name

@GinaGeorgescul
Copy link
Author

I did not :|, thank you so much for the quick answer.
The correct properties are:

quarkus.log.console.json.excluded-keys=loggerClassName,sequence,hostName,ndc,processId,processName,threadId
quarkus.log.console.json.key-overrides=thread-name=thread.name,level=log.level,logger-name=logger.name

As you mentioned, remove quotes, and also use kebab-case.

Do you know if it would be possible to replace some of them programmatically? (such as the mdc.traceId, when it exists)

@ozangunalp
Copy link
Contributor

AFAIK the MDC is logged separately.
If that is crucial to you, you can define a LoggingFilter and modify the log record: https://quarkus.io/guides/logging#add-a-logging-filter-to-your-log-handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logging kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants