TIBCO log4j Time Size Rolling Appender

Introduction

This is the TIBCO log4j Time Size Rolling Appender.

This log4j appender writes log4j messages to files and ensures a maximum size of each file never exceed a predefined maximum size. It also archives old files based on a time period, e.g. daily archive. The log4j configuration file, log4j.properties, is used to determine the configuration parameters.

Please see the enclosed javadoc.

Configuration

The following log4j options are available :-

Attribute Description
File Output file name.
FilePattern File name pattern used for rolled files. The pattern can contain the following conversion characters: 
 
%f - represents a File attribute value 
%d - represents an output file date in format defined by a DatePattern attribute 
%i - represents an output file index in format defined by a IndexPattern attribute 
 
Default FilePattern is %f.%i.%d
IndexPattern Index pattern defines a format of an output file index. For more information see DecimalFormat 
 
Default is 00, so the index will be 01, 02, 03 and so on.
DatePattern Date pattern defines a format of an output file date. and the rollover schedule (when TimeIntervalSeconds is not set ) For more information see SimpleDateFormat 
 
Default is yyyy-MM-dd
TimeIntervalSeconds Time Interval defines a rollover by time period in seconds. When used, the DatePattern will only be used for the format of output file name. 
 
Default is 0 (inactive). For example TimeIntervalSeconds=900 will rollover file every 15 minutes
MaxFileSize Max file size defines a maximum size of a file. 
 
Default is 10MB = 10485760
MaxBackupIndex Max backup index defines a maximum count of files generated for one time unit (e.g. day, hour, etc.) 
 
Default is 1.

An example log4j properties file is show below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#
# $Id: $
#
# Copyright 2013 TIBCO Software Inc. All rights reserved.
#
 
log4j.logger.test=DEBUG, CONSOLE, CDRFILE
log4j.logger.test_another=DEBUG, CONSOLE, ANOTHERCDRFILE
log4j.logger.test_count=DEBUG, CONSOLE, COUNTFILE
log4j.logger.test_roll=DEBUG, CONSOLE, ROLLFILE
 
 
 
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
 
log4j.appender.CDRFILE=com.tibco.logappender.TimeSizeRollingAppender
log4j.appender.CDRFILE.File=policy-CAS-PCRF-01.cdr
log4j.appender.CDRFILE.FilePattern=%f.%d.%i
log4j.appender.CDRFILE.IndexPattern=00
log4j.appender.CDRFILE.DatePattern=yyyy-MM-dd
log4j.appender.CDRFILE.MaxFileSize=500
log4j.appender.CDRFILE.MaxBackupIndex=1000
#log4j.appender.CDRFILE.TimeIntervalSeconds=900
log4j.appender.CDRFILE.Append=true
log4j.appender.CDRFILE.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.CDRFILE.layout.ConversionPattern=%m%n
log4j.additivity.com.tibco.policyframework.audit=false
 
log4j.appender.ANOTHERCDRFILE=com.tibco.logappender.TimeSizeRollingAppender
log4j.appender.ANOTHERCDRFILE.File=anotherpolicy-CAS-PCRF-01.cdr
log4j.appender.ANOTHERCDRFILE.FilePattern=%f.%d.%i
log4j.appender.ANOTHERCDRFILE.IndexPattern=00
log4j.appender.ANOTHERCDRFILE.DatePattern=yyyy-MM-dd-HH-mm-ss
log4j.appender.ANOTHERCDRFILE.MaxFileSize=500
log4j.appender.ANOTHERCDRFILE.MaxBackupIndex=1000
#log4j.appender.ANOTHERCDRFILE.TimeIntervalSeconds=900
log4j.appender.ANOTHERCDRFILE.Append=true
log4j.appender.ANOTHERCDRFILE.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.ANOTHERCDRFILE.layout.ConversionPattern=%m%n
 
 
log4j.appender.COUNTFILE=com.tibco.logappender.TimeSizeCountRollingAppender
log4j.appender.COUNTFILE.File=COUNT_FILE_%d
log4j.appender.COUNTFILE.FilePattern=%f_%d_NODE01_%N_%i
log4j.appender.COUNTFILE.IndexPattern=000000
#log4j.appender.COUNTFILE.DatePattern=yyyyMMddHHmmss
log4j.appender.COUNTFILE.DatePattern=yyyyMMddHHmm
log4j.appender.COUNTFILE.MaxFileSize=10000
log4j.appender.COUNTFILE.MaxRecords=10
log4j.appender.COUNTFILE.MaxBackupIndex=10000
log4j.appender.COUNTFILE.TimeIntervalSeconds=10
log4j.appender.COUNTFILE.ResetTimeIntervalSeconds=true
log4j.appender.COUNTFILE.WriteEmptyOnIntervalPassed=false
log4j.appender.COUNTFILE.UseOverallIndex=true
log4j.appender.COUNTFILE.OverallIndexStart=1000
log4j.appender.COUNTFILE.Append=false
log4j.appender.COUNTFILE.layout=com.tibco.logappender.HeaderFooterPatternLayout
log4j.appender.COUNTFILE.layout.ConversionPattern=%m%n
log4j.appender.COUNTFILE.layout.FixedHeader=HEADERRRRR
log4j.appender.COUNTFILE.layout.FixedFooter=FOOTERRRRR
 
 
 
log4j.appender.ROLLFILE=com.tibco.logappender.TimeSizeCountRollingAppender
log4j.appender.ROLLFILE.File=/tmp/cdr1/ROLL_FILE
log4j.appender.ROLLFILE.FilePattern=/tmp/cdr2/ROLL_FILE_%d_NODE01_%N_%i
log4j.appender.ROLLFILE.IndexPattern=000000
log4j.appender.ROLLFILE.DatePattern=yyyyMMddHHmm
log4j.appender.ROLLFILE.MaxFileSize=10000
log4j.appender.ROLLFILE.MaxRecords=3
log4j.appender.ROLLFILE.MaxBackupIndex=10000
log4j.appender.ROLLFILE.TimeIntervalSeconds=7
log4j.appender.ROLLFILE.ResetTimeIntervalSeconds=true
log4j.appender.ROLLFILE.WriteEmptyOnIntervalPassed=false
log4j.appender.ROLLFILE.UseOverallIndex=true
log4j.appender.ROLLFILE.OverallIndexStart=1000
log4j.appender.ROLLFILE.Append=true
log4j.appender.ROLLFILE.layout=com.tibco.logappender.HeaderFooterPatternLayout
log4j.appender.ROLLFILE.layout.ConversionPattern=%m%n
log4j.appender.ROLLFILE.layout.FixedHeader=HEADERRRRR
log4j.appender.ROLLFILE.layout.FixedFooter=FOOTERRRRR