<maxFileSize /> is the split size (kb and gb work too)
<maxHistory /> deletes logs older than 30 days, oldest first
SizeAndTimeBasedFNATP is the key part. Nesting it inside TimeBasedRollingPolicy is
what makes date and size apply together. That is also why the filename pattern needs
%i — within one day the file can roll several more times on size, so it needs an index.
Leaving out <maxHistory /> fills the disk. That is the most common server incident there is.
Switching Flume’s default logger from log4j to logback
Unpack and copy logback-classic-1.1.3.jar and logback-core-1.1.3.jar into
$FLUME_HOME/lib
Rename the existing ./lib/slf4j-log4j12-1.6.1.jar to
./lib/slf4j-log4j12-1.6.1.jar.back. Removing log4j is optional — leaving it in
means both will write
Put your logback.xml at $FLUME_HOME/conf/logback.xml
Two appenders is the point. daily holds Flume’s own logs, event holds the collected
events. Only the kimpaper logger writes to event, which keeps the collected data from
mixing with Flume’s operational logging.
Writing a custom collection sink
The plan was to use file_roll as the sink that gathers logs on the master server, but
it has drawbacks:
Routing the sink through slf4j means it picks up the rolling policy from the logback.xml
above. The filename is determined and maxHistory handles deletion — both drawbacks go
away at once.
From there, logs arriving from each server accumulate merged into collect.log.
Summary
To apply date and size together, nest SizeAndTimeBasedFNATP inside TimeBasedRollingPolicy
%i in the filename pattern is required — it can roll several times in one day
Always set maxHistory, or the disk fills
Switching Flume’s default logger to logback lets collected logs share the same rolling policy
Routing through an slf4j sink fixes file_roll’s filename and retention problems