Skip to content

Commit 132deb2

Browse files
committed
Revamp rolling file appender documentation
We split the documentation of rolling file appenders and minimize the repetition of configuration option descriptions and examples.
1 parent e2d14a7 commit 132deb2

28 files changed

+2574
-1166
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@
331331
<!-- Skipping `maven-site-plugin` globally. -->
332332
<maven.site.skip>true</maven.site.skip>
333333
<maven.site.deploy.skip>true</maven.site.deploy.skip>
334+
<site-commons-compress.version>1.26.2</site-commons-compress.version>
334335
<site-commons-csv.version>1.11.0</site-commons-csv.version>
335336
<site-commons-logging.version>1.3.3</site-commons-logging.version>
336337
<site-disruptor.version>4.0.0</site-disruptor.version>
@@ -728,6 +729,12 @@
728729

729730
<!-- Other dependencies -->
730731

732+
<dependency>
733+
<groupId>org.apache.commons</groupId>
734+
<artifactId>commons-compress</artifactId>
735+
<version>${site-commons-compress.version}</version>
736+
</dependency>
737+
731738
<dependency>
732739
<groupId>org.apache.commons</groupId>
733740
<artifactId>commons-csv</artifactId>

src/site/antora/antora.tmpl.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ asciidoc:
5151
lmax-disruptor-url: "https://lmax-exchange.github.io/disruptor/"
5252
slf4j-url: "https://www.slf4j.org"
5353
# Dependency versions
54+
commons-compress-version: "${site-commons-compress.version}"
5455
commons-csv-version: "${site-commons-csv.version}"
5556
commons-logging-version: "${site-commons-logging.version}"
5657
disruptor-version: "${site-disruptor.version}"

src/site/antora/antora.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ asciidoc:
5151
lmax-disruptor-url: "https://lmax-exchange.github.io/disruptor/"
5252
slf4j-url: "https://www.slf4j.org"
5353
# Dependency versions
54+
commons-compress-version: "1.2.3-commons-compress"
5455
commons-csv-version: "1.2.3-commons-csv"
5556
commons-logging-version: "1.2.3-commons-logging"
5657
disruptor-version: "1.2.3-disruptor"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"Configuration": {
3+
"Appenders": {
4+
// tag::appender[]
5+
"RollingFile": {
6+
"name": "FILE",
7+
"fileName": "/var/log/app.log",
8+
"filePattern": "/var/log/app.log.%i.gz", // <1>
9+
"JsonTemplateLayout": {},
10+
"DefaultRolloverStrategy": {
11+
"max": 15 // <2>
12+
},
13+
"Policies": {
14+
"CronTriggeringPolicy": {
15+
"schedule": "0 0 0 * * ?" // <3>
16+
},
17+
"SizeBasedTriggeringPolicy": {
18+
"size": "100k" // <4>
19+
}
20+
}
21+
}
22+
// end::appender[]
23+
},
24+
"Loggers": {
25+
"Root": {
26+
"level": "INFO",
27+
"AppenderRef": {
28+
"ref": "FILE"
29+
}
30+
}
31+
}
32+
}
33+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to you under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
##
18+
# tag::appender[]
19+
appender.0.type = RollingFile
20+
appender.0.name = FILE
21+
appender.0.fileName = /var/log/app.log
22+
# <1>
23+
appender.0.filePattern = /var/log/app.log.%i.gz
24+
25+
appender.0.layout.type = JsonTemplateLayout
26+
27+
appender.0.strategy.type = DefaultRolloveStrategy
28+
# <2>
29+
appender.0.strategy.max = 15
30+
31+
appender.0.policy.type = Policies
32+
appender.0.policy.0.type = CronTriggeringPolicy
33+
# <3>
34+
appender.0.policy.0.schedule = 0 0 0 * * ?
35+
appender.0.policy.1.type = SizeBasedTriggeringPolicy
36+
# <4>
37+
appender.0.policy.1.size = 100k
38+
# end::appender[]
39+
40+
rootLogger.level = INFO
41+
rootLogger.appenderRef.0.ref = FILE
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to you under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
<Configuration xmlns="https://logging.apache.org/xml/ns"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="
21+
https://logging.apache.org/xml/ns
22+
https://logging.apache.org/xml/ns/log4j-config-2.xsd">
23+
<Appenders>
24+
<!-- tag::appender[] -->
25+
<RollingFile name="FILE"
26+
fileName="/var/log/app.log"
27+
filePattern="/var/log/app.log.%i.gz"> <!--1-->
28+
<JsonTemplateLayout/>
29+
<DefaultRolloverStrategy max="15"/> <!--2-->
30+
<Policies>
31+
<CronTriggeringPolicy schedule="0 0 0 * * ?"/> <!--3-->
32+
<SizeBasedTriggeringPolicy size="100k"/> <!--4-->
33+
</Policies>
34+
</RollingFile>
35+
<!-- end::appender[] -->
36+
</Appenders>
37+
<Loggers>
38+
<Root level="INFO">
39+
<AppenderRef ref="FILE"/>
40+
</Root>
41+
</Loggers>
42+
</Configuration>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to you under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
Configuration:
18+
Appenders:
19+
# tag::appender[]
20+
RollingFile:
21+
name: "FILE"
22+
fileName: "/var/log/app.log"
23+
filePattern: "/var/log/app.log.%i.gz" # <1>
24+
JsonTemplateLayout: {}
25+
DefaultRolloverStrategy:
26+
max: 15 # <2>
27+
Policies:
28+
CronTriggeringPolicy:
29+
schedule: "0 0 0 * * ?" # <3>
30+
SizeBasedTriggeringPolicy:
31+
size: "100k" # <4>
32+
# end::appender[]
33+
Loggers:
34+
Root:
35+
level: "INFO"
36+
AppenderRef:
37+
ref: "FILE"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"Configuration": {
3+
"Appenders": {
4+
// tag::appender[]
5+
"RollingFile": {
6+
"name": "FILE",
7+
"filePattern": "/var/log/app/%{yyyy-MM}/%d{yyyy-MM-dd}.log.gz", // <1>
8+
"JsonTemplateLayout": {},
9+
"DirectWriteRolloverStrategy": {
10+
"Delete": {
11+
"basePath": "/var/log/app",
12+
"maxDepth": 2, // <2>
13+
"IfLastModified": {
14+
"age": "P90D"
15+
}
16+
}
17+
},
18+
"TimeBasedTriggeringPolicy": {}
19+
}
20+
// end::appender[]
21+
},
22+
"Loggers": {
23+
"Root": {
24+
"level": "INFO",
25+
"AppenderRef": {
26+
"ref": "FILE"
27+
}
28+
}
29+
}
30+
}
31+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to you under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
##
18+
# tag::appender[]
19+
appender.0.type = RollingFile
20+
appender.0.name = FILE
21+
# <1>
22+
appender.0.filePattern = /var/log/app/%d{yyyy-MM]/%d{yyyy-MM-dd}.log.gz
23+
24+
appender.0.layout.type = JsonTemplateLayout
25+
26+
appender.0.strategy.type = DirectWriteRolloverStrategy
27+
appender.0.strategy.delete.type = Delete
28+
appender.0.strategy.delete.basePath = /var/log/app
29+
# <2>
30+
appender.0.strategy.delete.maxDepth = 2
31+
appender.0.strategy.delete.0.type = IfLastModified
32+
appender.0.strategy.delete.0.age = P90D
33+
34+
appender.0.policy.type = TimeBaseTriggeringPolicy
35+
# end::appender[]
36+
37+
rootLogger.level = INFO
38+
rootLogger.appenderRef.0.ref = FILE
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to you under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
<Configuration xmlns="https://logging.apache.org/xml/ns"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="
21+
https://logging.apache.org/xml/ns
22+
https://logging.apache.org/xml/ns/log4j-config-2.xsd">
23+
<Appenders>
24+
<!-- tag::appender[] -->
25+
<RollingFile name="FILE"
26+
filePattern="/var/log/app/%d{yyyy-MM}/%d{yyyy-MM-dd}.log.gz"> <!--1-->
27+
<JsonTemplateLayout/>
28+
<DirectWriteRolloverStrategy>
29+
<Delete basePath="/var/log/app"
30+
maxDepth="2"> <!--2-->
31+
<IfLastModified age="P90D"/>
32+
</Delete>
33+
</DirectWriteRolloverStrategy>
34+
<TimeBasedTriggeringPolicy/>
35+
</RollingFile>
36+
<!-- end::appender[] -->
37+
</Appenders>
38+
<Loggers>
39+
<Root level="INFO">
40+
<AppenderRef ref="FILE"/>
41+
</Root>
42+
</Loggers>
43+
</Configuration>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to you under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
Configuration:
18+
Appenders:
19+
# tag::appender[]
20+
RollingFile:
21+
name: "FILE"
22+
filePattern: "/var/log/app/%d{yyyy-MM}/%d{yyyy-MM-dd}.log.gz" # <1>
23+
JsonTemplateLayout: {}
24+
DirectWriteRolloverStrategy:
25+
Delete:
26+
basePath: "/var/log/app"
27+
maxDepth: 2 # <2>
28+
IfLastModified:
29+
age: "P90D"
30+
TimeBasedTriggeringPolicy: {}
31+
# end::appender[]
32+
Loggers:
33+
Root:
34+
level: "INFO"
35+
AppenderRef:
36+
ref: "FILE"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"Configuration": {
3+
"Appenders": {
4+
// tag::appender[]
5+
"RollingFile": {
6+
"name": "FILE",
7+
"fileName": "app.log",
8+
"filePattern": "app.%d{yyyy-MM-dd}.%i.log",
9+
"JsonTemplateLayout": {},
10+
"Policies": {
11+
"OnStartupTriggeringPolicy": {},
12+
"SizeBasedTriggeringPolicy": {},
13+
"TimeBasedTriggeringPolicy": {}
14+
}
15+
}
16+
// end::appender[]
17+
},
18+
"Loggers": {
19+
"Root": {
20+
"level": "INFO",
21+
"AppenderRef": {
22+
"ref": "FILE"
23+
}
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)