Class DefaultConsoleHandler
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,org.jboss.logmanager.handlers.FlushableCloseable
ConsoleHandler preconfigured with Formatter.
Useful as a handler for java.util.logging.
If you have a logging.properties file (see LogManager.readConfiguration(InputStream)), you can use this handler by
setting the following properties:
handlers = eu.mulk.quarkus.googlecloud.jsonlogging.logmanager.DefaultConsoleHandler
Note: You can use org.slf4j.bridge.SLF4JBridgeHandler from
org.slf4j:jul-to-slf4j instead if you also have org.jboss.slf4j:slf4j-jboss-logmanager
on the class path. In comparison to this class, which relies on the relatively efficient ExtLogRecord.wrap(java.util.logging.LogRecord), routing through SLF4J incurs additional overhead because
of the necessary conversions between SLF4J's log entry structure and LogRecord.
Usage with Spring Boot
In case you are using Spring Boot, note that in addition to ensuring that
org.springframework.boot.logging.java.JavaLoggingSystem is the logging system in use (see
below), you need to accompany this with an entry in application.properties that points to
your logging.properties file:
logging.config = classpath:logging.properties
In order to ensure that Spring Boot chooses JavaLoggingSystem over other
implementations, make sure that no other logging backends are present on the class path. A simple
way of doing this is by relying on spring-boot-starter-logging while excluding Logback:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
You will probably want to include at least org.jboss.slf4j:slf4j-jboss-logmanager as
well. In addition, org.slf4j:jcl-over-slf4j,
org.jboss.logmanager:log4j-jboss-logmanager, and
org.jboss.logmanager:log4j2-jboss-logmanager may be useful, but are not required.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jboss.logmanager.handlers.ConsoleHandler
org.jboss.logmanager.handlers.ConsoleHandler.Target -
Field Summary
Fields inherited from class org.jboss.logmanager.handlers.WriterHandler
outputLockFields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater -
Constructor Summary
ConstructorsConstructorDescriptionConstructs console handler with a formatter created byFormatter.load(java.util.Collection<eu.mulk.quarkus.googlecloud.jsonlogging.StructuredParameterProvider>, java.util.Collection<eu.mulk.quarkus.googlecloud.jsonlogging.LabelProvider>). -
Method Summary
Methods inherited from class org.jboss.logmanager.handlers.ConsoleHandler
getLocalErrorManager, setErrorManager, setOutputStream, setTargetMethods inherited from class org.jboss.logmanager.handlers.OutputStreamHandler
getEncoding, setEncoding, setWriterMethods inherited from class org.jboss.logmanager.handlers.WriterHandler
close, doPublish, flush, preWrite, safeCloseMethods inherited from class org.jboss.logmanager.ExtHandler
addHandler, clearHandlers, getHandlers, isAutoFlush, isCallerCalculationRequired, isCloseChildren, isEnabled, publish, publish, publishToNestedHandlers, removeHandler, reportError, reportError, setAutoFlush, setCloseChildren, setEnabled, setFilter, setFormatter, setHandlers, setLevelMethods inherited from class java.util.logging.Handler
getErrorManager, getFilter, getFormatter, getLevel, isLoggable
-
Constructor Details
-
DefaultConsoleHandler
public DefaultConsoleHandler()Constructs console handler with a formatter created byFormatter.load(java.util.Collection<eu.mulk.quarkus.googlecloud.jsonlogging.StructuredParameterProvider>, java.util.Collection<eu.mulk.quarkus.googlecloud.jsonlogging.LabelProvider>).
-