Class DefaultingFileAppenderFactory<E extends ch.qos.logback.core.spi.DeferredProcessingAware>
- All Implemented Interfaces:
io.dropwizard.jackson.Discoverable,io.dropwizard.logging.common.AppenderFactory<E>
AppenderFactory implementation which extends FileAppenderFactory to provide default
values for the current log file name, archive log file name pattern, and log format if they are not explicitly
configured. Once the appender is built, these values can be retrieved from the factory instance using
FileAppenderFactory.getCurrentLogFilename(), FileAppenderFactory.getArchivedLogFilenamePattern(), and AbstractAppenderFactory.getLogFormat().
This factory provides the same properties available in FileAppenderFactory and one additional property
which allows you to easily use the default Dropwizard log format instead of the one provided here.
To use this in a Dropwizard application, the FQCN must be listed in a META-INF/services/io.dropwizard.logging.common.AppenderFactory
file. Dropwizard already provides this file with its own implementations (in the dropwizard-logging JAR).
This library also provides the same file with our implementation. These two files (and any others from other providers)
must all be combined so that the resulting file contains all implementations. We generally use the
Maven Shade Plugin with the
ServicesResourceTransformer
to combine these service files.
Last, in the logging configuration
of your Dropwizard configuration file, you can add an appender of type rollingWithDefaults.
- See Also:
-
AppenderFactoryFileAppenderFactoryRollingFileAppender
-
Field Summary
Fields inherited from class io.dropwizard.logging.common.AbstractAppenderFactory
layout, logFormat, threshold, timeZone -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionch.qos.logback.core.Appender<E>build(ch.qos.logback.classic.LoggerContext context, String applicationName, io.dropwizard.logging.common.layout.LayoutFactory<E> layoutFactory, io.dropwizard.logging.common.filter.LevelFilterFactory<E> levelFilterFactory, io.dropwizard.logging.common.async.AsyncAppenderFactory<E> asyncAppenderFactory) booleanIf true, uses the default Dropwizard log format provided byDropwizardLayout.voidsetUseDefaultDropwizardLogFormat(boolean useDefaultDropwizardLogFormat) If true, uses the default Dropwizard log format provided byDropwizardLayout.Methods inherited from class io.dropwizard.logging.common.FileAppenderFactory
appender, buildAppender, getArchivedFileCount, getArchivedLogFilenamePattern, getBufferSize, getCurrentLogFilename, getMaxFileSize, getTotalSizeCap, isArchive, isImmediateFlush, isMaxFileSizeSettingSpecified, isTotalSizeCapValid, isValidArchiveConfiguration, isValidFileConfiguration, isValidForMaxFileSizeSetting, setArchive, setArchivedFileCount, setArchivedLogFilenamePattern, setBufferSize, setCurrentLogFilename, setImmediateFlush, setMaxFileSize, setTotalSizeCapMethods inherited from class io.dropwizard.logging.common.AbstractAppenderFactory
buildLayout, getDiscardingThreshold, getFilterFactories, getLayout, getLogFormat, getMessageRate, getQueueSize, getThreshold, getTimeZone, isIncludeCallerData, setDiscardingThreshold, setFilterFactories, setIncludeCallerData, setLayout, setLogFormat, setMessageRate, setNeverBlock, setQueueSize, setThreshold, setTimeZone, setTimeZone, wrapAsync, wrapAsync
-
Constructor Details
-
DefaultingFileAppenderFactory
public DefaultingFileAppenderFactory()
-
-
Method Details
-
build
public ch.qos.logback.core.Appender<E> build(ch.qos.logback.classic.LoggerContext context, String applicationName, io.dropwizard.logging.common.layout.LayoutFactory<E> layoutFactory, io.dropwizard.logging.common.filter.LevelFilterFactory<E> levelFilterFactory, io.dropwizard.logging.common.async.AsyncAppenderFactory<E> asyncAppenderFactory) -
isUseDefaultDropwizardLogFormat
public boolean isUseDefaultDropwizardLogFormat()If true, uses the default Dropwizard log format provided byDropwizardLayout. -
setUseDefaultDropwizardLogFormat
public void setUseDefaultDropwizardLogFormat(boolean useDefaultDropwizardLogFormat) If true, uses the default Dropwizard log format provided byDropwizardLayout.
-