Logging configuration
Logging configuration Red Hat build of Quarkus 3.15 Red Hat Customer Content Services
import org.jboss.logging.Logger; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.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"; } } package com.example; import org.jboss.logging.Logger; public class MyService { private static final Logger log = Logger.getLogger(MyService.class); 1 public void doSomething() { log.info("It works!"); 2 } } package com.example; import io.quarkus.logging.Log; 1 class MyService { 2 public void doSomething() { Log.info("Simple!"); 3 } } package com.example; import org.jboss.logging.Logger; @ApplicationScoped class SimpleBean { @Inject Logger log; 1 @LoggerName("foo") Logger fooLog; 2 public void ping() { log.info("Simple!"); fooLog.info("Goes to _foo_ logger!"); } } quarkus.log.level=INFO quarkus.log.category."org.hibernate".level=DEBUG quarkus.log.category."org.hibernate".min-level=TRACE -Dquarkus.log.category.\"org.hibernate\".level=TRACE quarkus.log.handlers=con,mylog quarkus.log.handler.console.con.enable=true quarkus.log.handler.file.mylog.enable=true quarkus.log.category."org.apache.kafka.clients".level=INFO quarkus.log.category."org.apache.kafka.common.utils".level=INFO <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-logging-json</artifactId> </dependency> implementation("io.quarkus:quarkus-logging-json") %dev.quarkus.log.console.json=false %test.quarkus.log.console.json=false quarkus.log.console.format=%d{yyyy-MM-dd HH:mm:ss} %-5p [%c] (%t) %s%e%n quarkus.log.handler.console.my-console-handler.format=%d{yyyy-MM-dd HH:mm:ss} [com.example] %s%e%n quarkus.log.category."com.example".handlers=my-console-handler quarkus.log.category."com.example".use-parent-handlers=false quarkus.log.file.enable=true quarkus.log.file.path=application.log quarkus.log.file.format=%d{yyyy-MM-dd HH:mm:ss} %-5p [%c] (%t) %s%e%n quarkus.log.handler.file.my-file-handler.enable=true quarkus.log.handler.file.my-file-handler.path=application.log quarkus.log.handler.file.my-file-handler.format=%d{yyyy-MM-dd HH:mm:ss} [com.example] %s%e%n quarkus.log.category."com.example".handlers=my-file-handler quarkus.log.category."com.example".use-parent-handlers=false quarkus.log.syslog.enable=true quarkus.log.syslog.app-name=my-application quarkus.log.syslog.format=%d{yyyy-MM-dd HH:mm:ss} %-5p [%c] (%t) %s%e%n quarkus.log.handler.syslog.my-syslog-handler.enable=true quarkus.log.handler.syslog.my-syslog-handler.app-name=my-application quarkus.log.handler.syslog.my-syslog-handler.format=%d{yyyy-MM-dd HH:mm:ss} [com.example] %s%e%n quarkus.log.category."com.example".handlers=my-syslog-handler quarkus.log.category."com.example".use-parent-handlers=false package com.example; import io.quarkus.logging.LoggingFilter; import java.util.logging.Filter; import java.util.logging.LogRecord; @LoggingFilter(name = "my-filter") public final class TestFilter implements Filter { private final String part; public TestFilter(@ConfigProperty(name = "my-filter.part") String part) { this.part = part; } @Override public boolean isLoggable(LogRecord record) { return !record.getMessage().contains(part); } } my-filter.part=TEST quarkus.log.console.filter=my-filter quarkus.log.console.format=%d{HH:mm:ss} %-5p [%c{2.}] (%t) %s%e%n quarkus.log.console.level=DEBUG quarkus.console.color=false quarkus.log.category."io.quarkus".level=INFO quarkus.log.file.enable=true Send output to a trace.log file under the /tmp directory quarkus.log.file.path=/tmp/trace.log quarkus.log.file.level=TRACE quarkus.log.file.format=%d{HH:mm:ss} %-5p [%c{2.}] (%t) %s%e%n Set 2 categories (io.quarkus.smallrye.jwt, io.undertow.request.security) to TRACE level quarkus.log.min-level=TRACE quarkus.log.category."io.quarkus.smallrye.jwt".level=TRACE quarkus.log.category."io.undertow.request.security".level=TRACE Send output to a trace.log file under the /tmp directory quarkus.log.file.path=/tmp/trace.log quarkus.log.console.format=%d{HH:mm:ss} %-5p [%c{2.}] (%t) %s%e%n Configure a named handler that logs to console quarkus.log.handler.console."STRUCTURED_LOGGING".format=%e%n Configure a named handler that logs to file quarkus.log.handler.file."STRUCTURED_LOGGING_FILE".enable=true quarkus.log.handler.file."STRUCTURED_LOGGING_FILE".format=%e%n Configure the category and link the two named handlers to it quarkus.log.category."io.quarkus.category".level=INFO quarkus.log.category."io.quarkus.category".handlers=STRUCTURED_LOGGING,STRUCTURED_LOGGING_FILE configure a named file handler that sends the output to 'quarkus.log' quarkus.log.handler.file.CONSOLE_MIRROR.enable=true quarkus.log.handler.file.CONSOLE_MIRROR.path=quarkus.log attach the handler to the root logger quarkus.log.handlers=CONSOLE_MIRROR <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>USD{surefire-plugin.version}</version> <configuration> <systemPropertyVariables> <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> 1 <quarkus.log.level>DEBUG</quarkus.log.level> 2 <maven.home>USD{maven.home}</maven.home> </systemPropertyVariables> </configuration> </plugin> </plugins> </build> test { systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager" } Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl <dependency> <groupId>org.jboss.logging</groupId> <artifactId>commons-logging-jboss-logging</artifactId> </dependency> implementation("org.jboss.logging:commons-logging-jboss-logging") <dependency> <groupId>org.jboss.logmanager</groupId> <artifactId>log4j-jboss-logmanager</artifactId> </dependency> implementation("org.jboss.logmanager:log4j-jboss-logmanager") <dependency> <groupId>org.jboss.logmanager</groupId> <artifactId>log4j2-jboss-logmanager</artifactId> </dependency> implementation("org.jboss.logmanager:log4j2-jboss-logmanager") <dependency> <groupId>org.jboss.slf4j</groupId> <artifactId>slf4j-jboss-logmanager</artifactId> </dependency> implementation("org.jboss.slf4j:slf4j-jboss-logmanager") package me.sample; import io.quarkus.logging.Log; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import org.jboss.logmanager.MDC; import java.util.UUID; @Path("/hello/jboss") public class GreetingResourceJbossLogging { @GET @Path("/test") public String greeting() { MDC.put("request.id", UUID.randomUUID().toString()); MDC.put("request.path", "/hello/test"); Log.info("request received"); return "hello world!"; } } quarkus.log.console.format=%d{HH:mm:ss} %-5p request.id=%X{request.id} request.path=%X{request.path} [%c{2.}] (%t) %s%n 08:48:13 INFO request.id=c37a3a36-b7f6-4492-83a1-de41dbc26fe2 request.path=/hello/test [me.sa.GreetingResourceJbossLogging] (executor-thread-1) request received