Why use the isTraceEnabled () function in JBoss?

I am using the org.jboss.logging.Logger class and seem to have encountered a mismatch. When I have an error or warning, I just have to use logger.error("error message") or logger.warn("warning message") and it will be displayed based on the settings in the jboss-log4j.xml file.

However, based on existing jboss code, this discussion and this link , when using tracing, you must first determine if this is allowed using logger.isTraceEnabled() . Why does it seem that I should do this only for tracking?

+4
source share
1 answer

You should not". Without him, everything will be fine. However, TRACE-level logging tends to be verbose and can take up a significant amount of processor time, even if it was not ultimately logged to a file. By placing an if check around the registration operator, you avoid this overhead.

I have seen other good quality codes do the same for registering the DEBUG and INFO level, so it is not limited to TRACE.

See the log4j format section of the manual.

+8
source

Source: https://habr.com/ru/post/1399221/


All Articles