public class FileAppenderFactory<E extends ch.qos.logback.core.spi.DeferredProcessingAware> extends AbstractAppenderFactory<E>
AppenderFactory
implementation which provides an appender that writes events to a file, archiving older
files as it goes.
Configuration Parameters:
Name | Default | Description |
type |
REQUIRED | The appender type. Must be file . |
threshold |
ALL |
The lowest level of events to write to the file. |
currentLogFilename |
REQUIRED | The filename where current events are logged. |
archive |
true |
Whether or not to archive old events in separate files. |
archivedLogFilenamePattern |
REQUIRED if archive is true . |
The filename pattern for archived files.
If maxFileSize is specified, rollover is size-based, and the pattern must contain %i for
an integer index of the archived file.
Otherwise rollover is date-based, and the pattern must contain %d , which is replaced with the
date in yyyy-MM-dd form.
If the pattern ends with .gz or .zip , files will be compressed as they are archived.
|
archivedFileCount |
5 |
The number of archived files to keep. Must be greater than or equal to 0 . Zero is a
special value signifying to keep infinite logs (use with caution)
|
maxFileSize |
(unlimited) | The maximum size of the currently active file before a rollover is triggered. The value can be expressed in bytes, kilobytes, megabytes, gigabytes, and terabytes by appending B, K, MB, GB, or TB to the numeric value. Examples include 100MB, 1GB, 1TB. Sizes can also be spelled out, such as 100 megabytes, 1 gigabyte, 1 terabyte. |
timeZone |
UTC |
The time zone to which event timestamps will be converted. |
logFormat |
the default format | The Logback pattern with which events will be formatted. See the Logback documentation for details. |
AbstractAppenderFactory
logFormat, threshold, timeZone
Constructor and Description |
---|
FileAppenderFactory() |
Modifier and Type | Method and Description |
---|---|
ch.qos.logback.core.Appender<E> |
build(ch.qos.logback.classic.LoggerContext context,
String applicationName,
LayoutFactory<E> layoutFactory,
LevelFilterFactory<E> levelFilterFactory,
AsyncAppenderFactory<E> asyncAppenderFactory)
Given a Logback context, an application name, a layout,
a levelFilterFactory, and an asyncAppenderFactory build a new appender.
|
protected ch.qos.logback.core.FileAppender<E> |
buildAppender(ch.qos.logback.classic.LoggerContext context) |
int |
getArchivedFileCount() |
String |
getArchivedLogFilenamePattern() |
String |
getCurrentLogFilename() |
io.dropwizard.util.Size |
getMaxFileSize() |
boolean |
isArchive() |
boolean |
isMaxFileSizeSettingSpecified() |
boolean |
isValidArchiveConfiguration() |
boolean |
isValidFileConfiguration() |
boolean |
isValidForMaxFileSizeSetting() |
void |
setArchive(boolean archive) |
void |
setArchivedFileCount(int archivedFileCount) |
void |
setArchivedLogFilenamePattern(String archivedLogFilenamePattern) |
void |
setCurrentLogFilename(String currentLogFilename) |
void |
setMaxFileSize(io.dropwizard.util.Size maxFileSize) |
buildLayout, getDiscardingThreshold, getFilterFactories, getLogFormat, getQueueSize, getThreshold, getTimeZone, isIncludeCallerData, setDiscardingThreshold, setFilterFactories, setIncludeCallerData, setLogFormat, setQueueSize, setThreshold, setTimeZone, wrapAsync, wrapAsync
public String getCurrentLogFilename()
public void setCurrentLogFilename(String currentLogFilename)
public boolean isArchive()
public void setArchive(boolean archive)
public String getArchivedLogFilenamePattern()
public void setArchivedLogFilenamePattern(String archivedLogFilenamePattern)
public int getArchivedFileCount()
public void setArchivedFileCount(int archivedFileCount)
public io.dropwizard.util.Size getMaxFileSize()
public void setMaxFileSize(io.dropwizard.util.Size maxFileSize)
@ValidationMethod(message="must have archivedLogFilenamePattern if archive is true") public boolean isValidArchiveConfiguration()
@ValidationMethod(message="when specifying maxFileSize, archivedLogFilenamePattern must contain %i") public boolean isValidForMaxFileSizeSetting()
@ValidationMethod(message="when archivedLogFilenamePattern contains %i, maxFileSize must be specified") public boolean isMaxFileSizeSettingSpecified()
@ValidationMethod(message="currentLogFilename can only be null when archiving is enabled") public boolean isValidFileConfiguration()
public ch.qos.logback.core.Appender<E> build(ch.qos.logback.classic.LoggerContext context, String applicationName, LayoutFactory<E> layoutFactory, LevelFilterFactory<E> levelFilterFactory, AsyncAppenderFactory<E> asyncAppenderFactory)
AppenderFactory
context
- the Logback contextapplicationName
- the application namelayoutFactory
- the factory for the layout for logginglevelFilterFactory
- the factory for the level filterasyncAppenderFactory
- the factory for the async appenderAppender
protected ch.qos.logback.core.FileAppender<E> buildAppender(ch.qos.logback.classic.LoggerContext context)
Copyright © 2016. All rights reserved.