Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 1. JBoss LogManager and supported logging frameworks
Quarkus uses the JBoss LogManager logging backend to collect and manage log data. You can use JBoss Logging to collect data about Quarkus internal events and also about the events within your application. You can configure logging behavior in your application.properties file.
JBoss LogManager supports several third-party logging APIs in addition to the JBoss Logging. JBoss LogManager merges the logs from all the supported logging APIs.
Supported APIs for logging:
Quarkus handles all of its logging functionalities using JBoss Logging. When you use a library that relies on a different logging API, you need to exclude this library from the dependencies and configure JBoss Logging to use a logging adapter for the third-party API.
1.1. Adding Apache Log4j logging framework Link kopierenLink in die Zwischenablage kopiert!
Apache Log4j is a logging framework that includes a logging backend and a logging API. Since Quarkus uses the JBoss LogManager backend, you can add the log4j2-jboss-logmanager library to your project and use Log4j as a logging API. Adding the Log4j library routes the Log4j logs to the JBoss Log Manager. You do not need to include any Log4j dependencies.
Procedure
-
Add the
log4j2-jboss-logmanagerlibrary as a dependency of your project’spom.xmlfile:
pom.xml
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>log4j2-jboss-logmanager</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>log4j2-jboss-logmanager</artifactId>
</dependency>
The log4j2-jboss-logmanager is the library for the Log4J version 2 API. If you want to use the legacy Log4J version 1 API then you must add the log4j-jboss-logmanager instead.
1.2. Using logging adapters Link kopierenLink in die Zwischenablage kopiert!
Quarkus relies on the JBoss Logging library for all the logging requirements.
When you are using libraries that have dependencies on other logging libraries, such as Apache Commons Logging, Log4j, or SLF4j, you must exclude those logging libraries from the dependencies and use one of the adapters provided by JBoss Logging. You do not need to add an adapter for libraries that are dependencies of Quarkus extensions.
The third-party logging implementation is not included in the native executable and your application might fail to compile with an error message similar to the following:
Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl
Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl
You can prevent this error by configuring a JBoss Logging adapter for the third-party logging implementation that you use.
Procedure
Depending on the logging library that you are using, add one of the adapters to your
pom.xmlfile:Apache Commons Logging:
pom.xml
<dependency> <groupId>org.jboss.logging</groupId> <artifactId>commons-logging-jboss-logging</artifactId> </dependency><dependency> <groupId>org.jboss.logging</groupId> <artifactId>commons-logging-jboss-logging</artifactId> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Log4j:
pom.xml
<dependency> <groupId>org.jboss.logmanager</groupId> <artifactId>log4j-jboss-logmanager</artifactId> </dependency><dependency> <groupId>org.jboss.logmanager</groupId> <artifactId>log4j-jboss-logmanager</artifactId> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Log4j2:
pom.xml
<dependency> <groupId>org.jboss.logmanager</groupId> <artifactId>log4j2-jboss-logmanager</artifactId> </dependency><dependency> <groupId>org.jboss.logmanager</groupId> <artifactId>log4j2-jboss-logmanager</artifactId> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow SLF4j:
pom.xml
<dependency> <groupId>org.jboss.slf4j</groupId> <artifactId>slf4j-jboss-logmanager</artifactId> </dependency><dependency> <groupId>org.jboss.slf4j</groupId> <artifactId>slf4j-jboss-logmanager</artifactId> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow