You can see in https://logging.apache.org/log4j/2.x/manual/customloglevels.html the numerical values corresponding to built-in log4j2 logging levels, for example INFO->400. How can you refer to it in patternlayout resp. in JDBC Logger configuration?
I have an old log4j 1.x config for JDBC where it was referred as %iprio.
A workaround is to use
level{OFF=0,FATAL=100,ERROR=200,WARN=300,INFO=400,DEBUG=500,TRACE=600,ALL=1000}
but I am not very happy about that.
It sounds like you want to log the integer value of the log level instead of the name and you don't want to use the labeling feature of the
PatternLayout'slevelparameter.One possible solution would be to create a custom
Lookup, here is some sample code:Next, here is a sample configuration using the new lookup - note the
${level:}:Here is some sample code that performs some logging:
and finally here is the output:
Hope this helps!