diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 94a4e9f299d3a..5deb562d20686 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -200,6 +200,7 @@ 2.8.6 0.46 1.0.0.Beta1 + 1.2.0.Final 1.10.0 @@ -1991,6 +1992,11 @@ log4j2-jboss-logmanager ${log4j2-jboss-logmanager.version} + + org.jboss.logmanager + log4j-jboss-logmanager + ${log4j-jboss-logmanager.version} + io.quarkus.gizmo diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/LogConfig.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/LogConfig.java index 1e5a257ee0d42..a32aa18da40c4 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/logging/LogConfig.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/LogConfig.java @@ -17,23 +17,29 @@ public final class LogConfig { /** * The log level of the root category, which is used as the default log level for all categories. * - * In addition to the standard JDK log level JBoss Logging also adds the following: + * JBoss Logging supports Apache style log levels: * - * {@link org.jboss.logmanager.Level#FATAL} - * {@link org.jboss.logmanager.Level#ERROR} - * {@link org.jboss.logmanager.Level#WARN} - * {@link org.jboss.logmanager.Level#INFO} - * {@link org.jboss.logmanager.Level#DEBUG} - * {@link org.jboss.logmanager.Level#TRACE} + * * {@link org.jboss.logmanager.Level#FATAL} + * * {@link org.jboss.logmanager.Level#ERROR} + * * {@link org.jboss.logmanager.Level#WARN} + * * {@link org.jboss.logmanager.Level#INFO} + * * {@link org.jboss.logmanager.Level#DEBUG} + * * {@link org.jboss.logmanager.Level#TRACE} * + * In addition, it also supports the standard JDK log levels. + * + * @asciidoclet */ @ConfigItem(defaultValue = "INFO") public Level level; /** * The default minimum log level + * + * @deprecated this functionality was never implemented, it may be deleted or implemented in a future release. */ @ConfigItem(defaultValue = "INFO") + @Deprecated public Level minLevel; /** diff --git a/docs/src/main/asciidoc/logging.adoc b/docs/src/main/asciidoc/logging.adoc index 29555c286e86c..32a32cec44380 100644 --- a/docs/src/main/asciidoc/logging.adoc +++ b/docs/src/main/asciidoc/logging.adoc @@ -9,10 +9,95 @@ include::./attributes.adoc[] This guide explains logging and how to configure it. +Internally, Quarkus uses JBoss Log Manager and the JBoss Logging facade. + +You can use the JBoss Logging facade inside your code as it's already provided, +or any of the supported Logging API listed in the next chapter as Quarkus will send them to JBoss Log Manager. + +All the logging configuration will then be done inside your `application.properties`. + +== Supported Logging APIs + +Applications and components may use any of the following APIs for logging, and the logs will be merged: + +* JDK `java.util.logging` (also called JUL) +* https://github.com/jboss-logging/jboss-logging[JBoss Logging] +* https://www.slf4j.org/[SLF4J] +* https://commons.apache.org/proper/commons-logging/[Apache Commons Logging] + +Internally Quarkus uses JBoss Logging; you can also use it inside your application so that no other dependencies should be added for your logs. + +[source,java] +---- +import org.jboss.logging.Logger; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("/hello") +public class ExampleResource { + + private static final Logger LOG = Logger.getLogger(ExampleResource.class); + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String hello() { + LOG.info("Hello"); + return "hello"; + } +} +---- + +NOTE: If you use JBoss Logging but one of your libraries uses a different logging API, you may need to configure a link:#logging-adapters[Logging Adapter]. + +=== What about Apache Log4j ? + +link:https://logging.apache.org/log4j/2.x/[Log4j] is a logging implementation: it contains a logging backend and a logging facade. +Quarkus uses the JBoss Log Manager backend, so you will need to include the `log4j2-jboss-logmanager` library to route Log4j logs to JBoss Log Manager. + +[source,xml] +---- + + org.jboss.logmanager + log4j2-jboss-logmanager <1> + +---- + +<1> This is the library needed for Log2J version 2; if you use the legacy Log4J version 1 you need to use `log4j-jboss-logmanager` instead. + +You can then use the Log4J API inside your application. + +WARNING: Do not include any Log4j dependencies. The `log4j2-jboss-logmanager` library includes what's needed to use Log4j as a logging facade. + +== Logging levels + +These are the log levels used by Quarkus: + +[horizontal] +OFF:: Special level to turn off logging. +FATAL:: A critical service failure/complete inability to service requests of any kind. +ERROR:: A significant disruption in a request or the inability to service a request. +WARN:: A non-critical service error or problem that may not require immediate correction. +INFO:: Service lifecycle events or important related very-low-frequency information. +DEBUG:: Messages that convey extra information regarding lifecycle or non-request-bound events which may be helpful for debugging. +TRACE:: Messages that convey extra per-request debugging information that may be very high frequency. +ALL:: Special level for all messages including custom levels. + +In addition, the following levels may be configured for applications and libraries using link:https://docs.oracle.com/javase/8/docs/api/java/util/logging/Level.html[`java.util.logging`]: + +[horizontal] +SEVERE:: Same as **ERROR**. +WARNING:: Same as **WARN**. +CONFIG:: Service configuration information. +FINE:: Same as **DEBUG**. +FINER:: Same as **TRACE**. +FINEST:: Event more debugging information than `TRACE`, maybe with even higher frequency. + == Runtime configuration Run time logging is configured in the `application.properties` file, -for example to set everything to `INFO` logging except Hibernate: +for example, to set the default log level to `INFO` logging and include Hibernate `DEBUG` logs: [source, properties] ---- @@ -54,23 +139,14 @@ The root logger category is handled separately, and is configured via the follow |quarkus.log.level|INFO|The default minimum log level for every log category. |=== -=== Log levels +If no level configuration exists for a given logger category, the enclosing (parent) category is examined. If no categories are configured which enclose the category in question, then the root logger configuration is used. -There are several log levels you can use: +== Logging Format -[cols=" ---- +NOTE: This is not needed for libraries that are dependencies of a Quarkus extension as the extension will take care of this for you. + [[loggingConfigurationReference]] == Logging configuration reference