Skip to content

Commit a884e99

Browse files
committed
Revamp database appenders
This PR splits the documentation of database appenders into their own files. As in the previous PRs we: * check and reformat the configuration options, * add links to the Plugin Reference, * improve the readability of the description by shortening it and reformatting it,
1 parent eaae9e3 commit a884e99

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3107
-1148
lines changed

log4j-jpa/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<description>Apache Log4j Java Persistence API Appender.</description>
3333

3434
<properties>
35+
<maven.javadoc.skip>false</maven.javadoc.skip>
3536

3637
<!--
3738
~ OSGi and JPMS options
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
package com.example.logging;
18+
19+
import javax.persistence.Column;
20+
import javax.persistence.Entity;
21+
import javax.persistence.GeneratedValue;
22+
import javax.persistence.GenerationType;
23+
import javax.persistence.Id;
24+
import javax.persistence.Table;
25+
import org.apache.logging.log4j.core.LogEvent;
26+
27+
// tag::entity[]
28+
@Entity
29+
@Table(name = "log")
30+
public class LogEventEntity extends BasicLogEventEntity {
31+
private static final long serialVersionUID = 1L;
32+
private long id;
33+
// <1>
34+
public LogEventEntity() {}
35+
// <2>
36+
public LogEventEntity(final LogEvent wrapped) {
37+
super(wrapped);
38+
}
39+
// <3>
40+
@Id
41+
@GeneratedValue(strategy = GenerationType.IDENTITY)
42+
@Column(name = "id")
43+
public long getId() {
44+
return id;
45+
}
46+
// tag::setter[]
47+
public void setId(final long id) {
48+
this.id = id;
49+
}
50+
// end::setter[]
51+
}
52+
// end::entity[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"Configuration": {
3+
"Appenders": {
4+
// tag::appender[]
5+
"Cassandra": {
6+
"name": "CASSANDRA",
7+
"clusterName": "test-cluster",
8+
"keyspace": "test",
9+
"table": "logs",
10+
// <1>
11+
"bufferSize": 10,
12+
"batched": true,
13+
// <2>
14+
"SocketAddress": [
15+
{
16+
"host": "server1",
17+
"port": "9042"
18+
},
19+
{
20+
"host": "server2",
21+
"port": "9042"
22+
}
23+
],
24+
// <3>
25+
"ColumnMapping": [
26+
{
27+
"name": "id",
28+
"pattern": "%uuid{TIME}",
29+
"columnType": "java.util.UUID"
30+
},
31+
{
32+
"name": "timestamp",
33+
"columnType": "java.util.Date"
34+
},
35+
{
36+
"name": "level",
37+
"pattern": "%level"
38+
},
39+
{
40+
"name": "marker",
41+
"pattern": "%marker"
42+
},
43+
{
44+
"name": "logger",
45+
"pattern": "%logger"
46+
},
47+
{
48+
"name": "message",
49+
"pattern": "%m"
50+
},
51+
{
52+
"name": "mdc",
53+
"columnType": "org.apache.logging.log4j.spi.ThreadContextMap"
54+
},
55+
{
56+
"name": "ndc",
57+
"columnType": "org.apache.logging.log4j.spi.ThreadContextStack"
58+
}
59+
]
60+
}
61+
// end::appender[]
62+
},
63+
"Loggers": {
64+
"Root": {
65+
"level": "INFO",
66+
"AppenderRef": {
67+
"ref": "CASSANDRA"
68+
}
69+
}
70+
}
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 = Cassandra
20+
appender.0.name = CASSANDRA
21+
appender.0.clusterName = test-cluster
22+
appender.0.keyspace = test
23+
appender.0.table = logs
24+
# <1>
25+
appender.0.bufferSize = 10
26+
appender.0.batched = true
27+
28+
# <2>
29+
appender.0.addr[0].type = SocketAddress
30+
appender.0.addr[0].host = server1
31+
appender.0.addr[0].port = 9042
32+
33+
appender.0.addr[1].type = SocketAddress
34+
appender.0.addr[1].host = server2
35+
appender.0.addr[1].port = 9042
36+
37+
# <3>
38+
appender.0.col[0].type = ColumnMapping
39+
appender.0.col[0].name = uuid
40+
appender.0.col[0].pattern = %uuid{TIME}
41+
appender.0.col[0].columnType = java.util.UUID
42+
43+
appender.0.col[1].type = ColumnMapping
44+
appender.0.col[1].name = timestamp
45+
appender.0.col[1].timestamp = java.util.Date
46+
47+
appender.0.col[2].type = ColumnMapping
48+
appender.0.col[2].name = level
49+
appender.0.col[2].pattern = %level
50+
51+
appender.0.col[3].type = ColumnMapping
52+
appender.0.col[3].name = marker
53+
appender.0.col[3].pattern = %marker
54+
55+
appender.0.col[4].type = ColumnMapping
56+
appender.0.col[4].name = logger
57+
appender.0.col[4].pattern = %logger
58+
59+
appender.0.col[5].type = ColumnMapping
60+
appender.0.col[5].name = message
61+
appender.0.col[5].pattern = %message
62+
63+
appender.0.col[6].type = ColumnMapping
64+
appender.0.col[6].name = mdc
65+
appender.0.col[6].columnType = org.apache.logging.log4j.spi.ThreadContextMap
66+
67+
appender.0.col[7].type = ColumnMapping
68+
appender.0.col[7].name = ndc
69+
appender.0.col[7].columnType = org.apache.logging.log4j.spi.ThreadContextStack
70+
# end::appender[]
71+
72+
rootLogger.level = INFO
73+
rootLogger.appenderRef.0.ref= CASSANDRA
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
CREATE TABLE logs
18+
(
19+
id timeuuid PRIMARY KEY,
20+
level text,
21+
marker text,
22+
logger text,
23+
message text,
24+
timestamp timestamp,
25+
mdc map<text,text>,
26+
ndc list<text>
27+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
<Cassandra name="CASSANDRA"
26+
clusterName="test-cluster"
27+
keyspace="test"
28+
table="logs"
29+
bufferSize="10"
30+
batched="true"> <!--1-->
31+
<!--2-->
32+
<SocketAddress host="server1" port="9042"/>
33+
<SocketAddress host="server2" port="9042"/>
34+
<!--3-->
35+
<ColumnMapping name="id"
36+
pattern="%uuid{TIME}"
37+
columnType="java.util.UUID"/>
38+
<ColumnMapping name="timestamp" columnType="java.util.Date"/>
39+
<ColumnMapping name="level" pattern="%level"/>
40+
<ColumnMapping name="marker" pattern="%marker"/>
41+
<ColumnMapping name="logger" pattern="%logger"/>
42+
<ColumnMapping name="message" pattern="%message"/>
43+
<ColumnMapping name="mdc"
44+
columnType="org.apache.logging.log4j.spi.ThreadContextMap"/>
45+
<ColumnMapping name="ndc"
46+
columnType="org.apache.logging.log4j.spi.ThreadContextStack"/>
47+
</Cassandra>
48+
<!-- end::appender[] -->
49+
</Appenders>
50+
<Loggers>
51+
<Root level="INFO">
52+
<AppenderRef ref="CASSANDRA"/>
53+
</Root>
54+
</Loggers>
55+
</Configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
Cassandra:
21+
name: "CASSANDRA"
22+
clusterName: "test-cluster"
23+
keyspace: "test"
24+
table: "logs"
25+
# <1>
26+
bufferSize: 10
27+
batched: true
28+
# <2>
29+
SocketAddress:
30+
- host: "server1"
31+
port: "9042"
32+
- host: "server2"
33+
port: "9042"
34+
# <3>
35+
ColumnMapping:
36+
- name: "id"
37+
pattern: "%uuid{TIME}"
38+
columnType: "java.util.UUID"
39+
- name: "timestamp"
40+
columnType: "java.util.Date"
41+
- name: "level"
42+
pattern: "%level"
43+
- name: "marker"
44+
pattern: "%marker"
45+
- name: "logger"
46+
pattern: "%logger"
47+
- name: "message"
48+
pattern: "%message"
49+
- name: "mdc"
50+
columnType: "org.apache.logging.log4j.spi.ThreadContextMap"
51+
- name: "ndc"
52+
columnType: "org.apache.logging.log4j.spi.ThreadContextStack"
53+
# end::appender[]
54+
Loggers:
55+
Root:
56+
level: "INFO"
57+
AppenderRef:
58+
ref: "CASSANDRA"

0 commit comments

Comments
 (0)