Quarkus - Configuring Logging
This guide explains logging and how to configure it.
Run Time Configuration
Run time configuration of logging is done through the normal application.properties
file.
Configuration property fixed at build time - ️ Configuration property overridable at runtime
Configuration property | Type | Default |
---|---|---|
quarkus.log.level The default log level | Level | |
quarkus.log.min-level The default minimum log level | Level | INFO |
Logging categories | Type | Default |
quarkus.log.category."categories".min-level The minimum level that this category can be set to | string | inherit |
quarkus.log.category."categories".level The log level level for this category | string | inherit |
Console logging | Type | Default |
quarkus.log.console.enable If console logging should be enabled | boolean | true |
quarkus.log.console.format The log format | string | %d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{3.}] (%t) %s%e%n |
quarkus.log.console.level The console log level | Level | ALL |
quarkus.log.console.color If the console logging should be in color. If undefined quarkus takes best guess based on operating system and environment. | boolean | |
quarkus.log.console.darken Specify how much the colors should be darkened | int | 0 |
quarkus.log.console.async Indicates whether to log asynchronously | boolean | false |
quarkus.log.console.async.queue-length The queue length to use before flushing writing | int | 512 |
quarkus.log.console.async.overflow Determine whether to block the publisher (rather than drop the message) when the queue is full | block , discard | block |
File logging | Type | Default |
quarkus.log.file.enable If file logging should be enabled | boolean | false |
quarkus.log.file.format The log format | string | %d{yyyy-MM-dd HH:mm:ss,SSS} %h %N[%i] %-5p [%c{3.}] (%t) %s%e%n |
quarkus.log.file.level The level of logs to be written into the file. | Level | ALL |
quarkus.log.file.path The name of the file in which logs will be written. | File | quarkus.log |
quarkus.log.file.async Indicates whether to log asynchronously | boolean | false |
quarkus.log.file.async.queue-length The queue length to use before flushing writing | int | 512 |
quarkus.log.file.async.overflow Determine whether to block the publisher (rather than drop the message) when the queue is full | block , discard | block |
quarkus.log.file.rotation.max-file-size The maximum file size of the log file after which a rotation is executed. | MemorySize | |
quarkus.log.file.rotation.max-backup-index The maximum number of backups to keep. | int | 1 |
quarkus.log.file.rotation.file-suffix File handler rotation file suffix. Example fileSuffix: .yyyy-MM-dd | string | |
quarkus.log.file.rotation.rotate-on-boot Indicates whether to rotate log files on server initialization. | boolean | true |
Syslog logging | Type | Default |
quarkus.log.syslog.enable If syslog logging should be enabled | boolean | false |
quarkus.log.syslog.endpoint The IP address and port of the syslog server | host:port | localhost:514 |
quarkus.log.syslog.app-name The app name used when formatting the message in RFC5424 format | string | |
quarkus.log.syslog.hostname The name of the host the messages are being sent from | string | |
quarkus.log.syslog.facility Sets the facility used when calculating the priority of the message as defined by RFC-5424 and RFC-3164 | kernel , user-level , mail-system , system-daemons , security , syslogd , line-printer , network-news , uucp , clock-daemon , security2 , ftp-daemon , ntp , log-audit , log-alert , clock-daemon2 , local-use-0 , local-use-1 , local-use-2 , local-use-3 , local-use-4 , local-use-5 , local-use-6 , local-use-7 | user-level |
quarkus.log.syslog.syslog-type Set the SyslogType syslog type this handler should use to format the message sent | rfc5424 , rfc3164 | rfc5424 |
quarkus.log.syslog.protocol Sets the protocol used to connect to the syslog server | tcp , udp , ssl-tcp | tcp |
quarkus.log.syslog.use-counting-framing Set to true if the message being sent should be prefixed with the size of the message | boolean | false |
quarkus.log.syslog.truncate Set to true if the message should be truncated | boolean | true |
quarkus.log.syslog.block-on-reconnect Enables or disables blocking when attempting to reconnect a org.jboss.logmanager.handlers.SyslogHandler.Protocol#TCPTCP or org.jboss.logmanager.handlers.SyslogHandler.Protocol#SSL_TCP SSL TCP protocol | boolean | false |
quarkus.log.syslog.format The log message format | string | %d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{3.}] (%t) %s%e%n |
quarkus.log.syslog.level The log level specifying, which message levels will be logged by syslog logger | Level | ALL |
quarkus.log.syslog.async Indicates whether to log asynchronously | boolean | false |
quarkus.log.syslog.async.queue-length The queue length to use before flushing writing | int | 512 |
quarkus.log.syslog.async.overflow Determine whether to block the publisher (rather than drop the message) when the queue is full | block , discard | block |
Log cleanup filters - internal use | Type | Default |
quarkus.log.filter."filters".if-starts-with The message starts to match | list of string | inherit |
About the MemorySize formatA size configuration option recognises string in this format (shown as a regular expression): [0-9]+[KkMmGgTtPpEeZzYy]? .If no suffix is given, assume bytes. |
Logging categories
Logging is done on a per-category basis. Each category can be independently configured.A configuration which applies to a category will also apply to all sub-categories of that category,unless there is a more specific matching sub-category configuration.
Property Name | Default | Description |
---|---|---|
quarkus.log.category."<category-name>".level | INFO [1] | The level to use to configure the category named <category-name> . The quotes are necessary. |
The quotes shown in the property name are required as categories normally contain '.' which mustbe escaped. An example is shown in File TRACE Logging Configuration. |
Root logger configuration
The root logger category is handled separately, and is configured via the following properties:
Property Name | Default | Description |
---|---|---|
quarkus.log.level | INFO | The default minimum log level for every log category. |
Format String
The logging format string supports the following symbols:
Symbol | Summary | Description |
---|---|---|
%% | % | Renders a simple % character. |
%c | Category | Renders the category name. |
%C | Source class | Renders the source class name.[2] |
%d{xxx} | Date | Renders a date with the given date format string, which uses the syntax defined by java.text.SimpleDateFormat . |
%e | Exception | Renders the thrown exception, if any. |
%F | Source file | Renders the source file name.[2] |
%h | Host name | Renders the system simple host name. |
%H | Qualified host name | Renders the system’s fully qualified host name, which may be the same as the simple host name, depending on OS configuration. |
%i | Process ID | Render the current process PID. |
%l | Source location | Renders the source location information, which includes source file name, line number, class name, and method name.[2] |
%L | Source line | Renders the source line number.[2] |
%m | Full Message | Renders the log message plus exception (if any). |
%M | Source method | Renders the source method name.[2] |
%n | Newline | Renders the platform-specific line separator string. |
%N | Process name | Render the name of the current process. |
%p | Level | Render the log level of the message. |
%r | Relative time | Render the time in milliseconds since the start of the application log. |
%s | Simple message | Renders just the log message, with no exception trace. |
%t | Thread name | Render the thread name. |
%t{id} | Thread ID | Render the thread ID. |
%z{<zone name>} | Time zone | Set the time zone of the output to <zone name> . |
%X{<MDC property name>} | Mapped Diagnostics Context Value | Renders the value from Mapped Diagnostics Context |
%X | Mapped Diagnostics Context Values | Renders all the values from Mapped Diagnostics Context in format {property.key=property.value} |
%x | Nested Diagnostics context values | Renders all the values from Nested Diagnostics Context in format {value1.value2} |
Examples
Console DEBUG Logging, No color, Shortened Time, Shortened Category Prefixes
quarkus.log.console.enable=true
quarkus.log.console.format=%d{HH:mm:ss} %-5p [%c{2.}] (%t) %s%e%n
quarkus.log.console.level=DEBUG
quarkus.log.console.color=false
quarkus.log.category."io.quarkus".level=DEBUG
If you are adding these properties via command line make sure " is escaped.For example -Dquarkus.log.category.\"io.quarkus\".level=DEBUG . |
File TRACE Logging Configuration
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.category."io.quarkus.smallrye.jwt".level=TRACE
quarkus.log.category."io.undertow.request.security".level=TRACE
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
1. Some extensions may define customized default log levels for certain categories, in order to reduce log noise by default. Setting the log level in configuration will override any extension-defined log levels.
2. Format sequences which examine caller information may affect performance