Logging

tapir uses Log4j2 as logging framework.

Configuration

tapir does not recommend any configuration style. You can configure Log4j2 the way you prefer. Just take a look at https://logging.apache.org/log4j/2.x/manual/configuration.html.

Anyway, if you prefer using a xml file this one is a good starting point. It is generated by our archetype as well:

log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>
    </Appenders>
    <Loggers>
        <Root level="info">
            <AppenderRef ref="Console" />
        </Root>
    </Loggers>
</Configuration>

What about third-party libraries?

tapir uses bridges to redirect the logging output of logging frameworks which are used by third-party libraries to Log4j2. That has the advantage that you can configure all loggers with a Log4j2 configuration.

We analyzed the logging frameworks which our third-party libraries used and included the corresponding bridges in the tapir-depenencies module. If you add additional frameworks with additional logging frameworks you have to add the bridge by yourself.

The following logging frameworks are bridged out-of-the-box:

Caution
Due to http://logging.apache.org/log4j/2.x/log4j-1.2-api/index.html we have to exclude the Log4j 1.x jars
  • SLF4J
  • Apache Commons Logging
  • java.util.logging (JUL)