quarkus
quarkus copied to clipboard
Named handlers for a category in gelf not supported
Describe the bug According to quarkus documentation, named handlers can be added and attached to categories: https://quarkus.io/guides/logging#category-example
It is not supported with gelf however.
Expected behavior custom handlers should be supported with their own configs like additional fields.
Actual behavior Configuration produces a warning at startup
Unrecognized configuration key "quarkus.log.handler.gelf."CUSTOM".additional-field.addfield.value" was provided; it will be ignored Unrecognized configuration key "quarkus.log.handler.gelf."CUSTOM".enable" was provided; it will be ignored
To Reproduce Steps to reproduce the behavior:
-
Add regular gelf config and the following: quarkus.log.handler.gelf."CUSTOM".enable=true quarkus.log.handler.gelf."CUSTOM".additional-field.addfield.value=custom quarkus.log.category."com.io.filter.FilteredLogger".handlers=CUSTOM
-
start the app, the warning is logged
Environment (please complete the following information):
- Output of
uname -a
orver
: Windows - Output of
java -version
: openjdk version "11" 2018-09-25 - Quarkus version or git rev: 1.3.2.Final
- Build tool (ie. output of
mvnw --version
orgradlew --version
): 3.6.3
Additional context The goal is that some loggers (categories) can add and overwrite GELFs additional fields.
/cc @loicmathieu
Named handlers are supported on standard handlers (the one incuded in the core quarkus library) but not in the logging-gelf
extension.
So this is a feature request not a bug, be careful that behind each GELF handler there is a socket to write to a server so I'm not sure it's a good idead to create multiple ones ...
Agree. Was not clear from documentation. I'm aware of separate sockets, but how else could we overwrite additional fields per category?
@blsouthr another solution would be to use MDC fields (https://logging.paluch.biz/mdc.html) but these are not currently exposed inside the logging-gelf
extension.
@loicmathieu Maybe some kind of filtering could be applied, so that filter given the log category could add/override additional fields. Something like:
quarkus.log.handler.gelf.filter."com.company.SomeClass".additional-field.addfield.fieldname=fieldvalue
that way no extra appender/socket would be needed
@loicmathieu I've implemented overriding of additional fields by extending JBoss7GelfLogHandler and overriding createGelfMessage method. Based on config it can then put additional values only for configured loggers E.g.
quarkus.log.handler.gelf.additional-filter."com.comp.SomeClass".fieldname.value=fieldvalue
It works for me, but I guess, you'd probably want to change config format
See gelf.zip
@blsouthr MDC is a standard logging mechanism, could it be used if we expose them ?
@loicmathieu I don't think so. Or, I don't know how MDC could help to achieve what I want
Hello guys, is there any update in this issue?
It would be great to be able to attach a category to the gelf logger. In the Wildfly Keycloak version we are using the socket logger to send the "org.keycloak.events" messages to logstash for audit logging. If it would be possible to send a certain category to logstash the functionality would be the same.