Class DefaultingFileAppenderFactory<E extends ch.qos.logback.core.spi.DeferredProcessingAware>
- java.lang.Object
-
- io.dropwizard.logging.AbstractAppenderFactory<E>
-
- io.dropwizard.logging.AbstractOutputStreamAppenderFactory<E>
-
- io.dropwizard.logging.FileAppenderFactory<E>
-
- org.kiwiproject.beta.dropwizard.DefaultingFileAppenderFactory<E>
-
- All Implemented Interfaces:
io.dropwizard.jackson.Discoverable,io.dropwizard.logging.AppenderFactory<E>
@Beta public class DefaultingFileAppenderFactory<E extends ch.qos.logback.core.spi.DeferredProcessingAware> extends io.dropwizard.logging.FileAppenderFactory<E>A DropwizardAppenderFactoryimplementation which extendsFileAppenderFactoryto 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 usingFileAppenderFactory.getCurrentLogFilename(),FileAppenderFactory.getArchivedLogFilenamePattern(), andAbstractAppenderFactory.getLogFormat().This factory provides the same properties available in
FileAppenderFactoryand 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.AppenderFactoryfile. Dropwizard already provides this file with its own implementations (in thedropwizard-loggingJAR). This library also provides the same file with our implementation. These two files (and any others from other providers) must all be combined so 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
appenderof typerollingWithDefaults.- See Also:
AppenderFactory,FileAppenderFactory,RollingFileAppender
-
-
Constructor Summary
Constructors Constructor Description DefaultingFileAppenderFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ch.qos.logback.core.Appender<E>build(ch.qos.logback.classic.LoggerContext context, String applicationName, io.dropwizard.logging.layout.LayoutFactory<E> layoutFactory, io.dropwizard.logging.filter.LevelFilterFactory<E> levelFilterFactory, io.dropwizard.logging.async.AsyncAppenderFactory<E> asyncAppenderFactory)booleanisUseDefaultDropwizardLogFormat()If 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.FileAppenderFactory
appender, buildAppender, getArchivedFileCount, getArchivedLogFilenamePattern, getBufferSize, getCurrentLogFilename, getMaxFileSize, getTotalSizeCap, isArchive, isImmediateFlush, isMaxFileSizeSettingSpecified, isTotalSizeCapValid, isValidArchiveConfiguration, isValidFileConfiguration, isValidForMaxFileSizeSetting, setArchive, setArchivedFileCount, setArchivedLogFilenamePattern, setBufferSize, setCurrentLogFilename, setImmediateFlush, setMaxFileSize, setTotalSizeCap
-
Methods inherited from class io.dropwizard.logging.AbstractAppenderFactory
buildLayout, getDiscardingThreshold, getFilterFactories, getLayout, getLogFormat, getMessageRate, getQueueSize, getThreshold, getTimeZone, isIncludeCallerData, setDiscardingThreshold, setFilterFactories, setIncludeCallerData, setLayout, setLogFormat, setMessageRate, setNeverBlock, setQueueSize, setThreshold, setTimeZone, setTimeZone, wrapAsync, wrapAsync
-
-
-
-
Method Detail
-
build
public ch.qos.logback.core.Appender<E> build(ch.qos.logback.classic.LoggerContext context, String applicationName, io.dropwizard.logging.layout.LayoutFactory<E> layoutFactory, io.dropwizard.logging.filter.LevelFilterFactory<E> levelFilterFactory, io.dropwizard.logging.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.
-
-