Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions log4j-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<description>Apache Log4j Java Persistence API Appender.</description>

<properties>
<maven.javadoc.skip>false</maven.javadoc.skip>

<!--
~ OSGi and JPMS options
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.logging;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.logging.log4j.core.LogEvent;

// tag::entity[]
@Entity
@Table(name = "log")
public class LogEventEntity extends BasicLogEventEntity {
private static final long serialVersionUID = 1L;
private long id;
// <1>
public LogEventEntity() {}
// <2>
public LogEventEntity(final LogEvent wrapped) {
super(wrapped);
}
// <3>
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
public long getId() {
return id;
}
// tag::setter[]
public void setId(final long id) {
this.id = id;
}
// end::setter[]
}
// end::entity[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"Configuration": {
"Appenders": {
// tag::appender[]
"Cassandra": {
"name": "CASSANDRA",
"clusterName": "test-cluster",
"keyspace": "test",
"table": "logs",
// <1>
"bufferSize": 10,
"batched": true,
// <2>
"SocketAddress": [
{
"host": "server1",
"port": "9042"
},
{
"host": "server2",
"port": "9042"
}
],
// <3>
"ColumnMapping": [
{
"name": "id",
"pattern": "%uuid{TIME}",
"columnType": "java.util.UUID"
},
{
"name": "timestamp",
"columnType": "java.util.Date"
},
{
"name": "level",
"pattern": "%level"
},
{
"name": "marker",
"pattern": "%marker"
},
{
"name": "logger",
"pattern": "%logger"
},
{
"name": "message",
"pattern": "%m"
},
{
"name": "mdc",
"columnType": "org.apache.logging.log4j.spi.ThreadContextMap"
},
{
"name": "ndc",
"columnType": "org.apache.logging.log4j.spi.ThreadContextStack"
}
]
}
// end::appender[]
},
"Loggers": {
"Root": {
"level": "INFO",
"AppenderRef": {
"ref": "CASSANDRA"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##
# tag::appender[]
appender.0.type = Cassandra
appender.0.name = CASSANDRA
appender.0.clusterName = test-cluster
appender.0.keyspace = test
appender.0.table = logs
# <1>
appender.0.bufferSize = 10
appender.0.batched = true

# <2>
appender.0.addr[0].type = SocketAddress
appender.0.addr[0].host = server1
appender.0.addr[0].port = 9042

appender.0.addr[1].type = SocketAddress
appender.0.addr[1].host = server2
appender.0.addr[1].port = 9042

# <3>
appender.0.col[0].type = ColumnMapping
appender.0.col[0].name = uuid
appender.0.col[0].pattern = %uuid{TIME}
appender.0.col[0].columnType = java.util.UUID

appender.0.col[1].type = ColumnMapping
appender.0.col[1].name = timestamp
appender.0.col[1].timestamp = java.util.Date

appender.0.col[2].type = ColumnMapping
appender.0.col[2].name = level
appender.0.col[2].pattern = %level

appender.0.col[3].type = ColumnMapping
appender.0.col[3].name = marker
appender.0.col[3].pattern = %marker

appender.0.col[4].type = ColumnMapping
appender.0.col[4].name = logger
appender.0.col[4].pattern = %logger

appender.0.col[5].type = ColumnMapping
appender.0.col[5].name = message
appender.0.col[5].pattern = %message

appender.0.col[6].type = ColumnMapping
appender.0.col[6].name = mdc
appender.0.col[6].columnType = org.apache.logging.log4j.spi.ThreadContextMap

appender.0.col[7].type = ColumnMapping
appender.0.col[7].name = ndc
appender.0.col[7].columnType = org.apache.logging.log4j.spi.ThreadContextStack
# end::appender[]

rootLogger.level = INFO
rootLogger.appenderRef.0.ref= CASSANDRA
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
CREATE TABLE logs
(
id timeuuid PRIMARY KEY,
level text,
marker text,
logger text,
message text,
timestamp timestamp,
mdc map<text,text>,
ndc list<text>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to you under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<Configuration xmlns="https://logging.apache.org/xml/ns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
https://logging.apache.org/xml/ns
https://logging.apache.org/xml/ns/log4j-config-2.xsd">
<Appenders>
<!-- tag::appender[] -->
<Cassandra name="CASSANDRA"
clusterName="test-cluster"
keyspace="test"
table="logs"
bufferSize="10"
batched="true"> <!--1-->
<!--2-->
<SocketAddress host="server1" port="9042"/>
<SocketAddress host="server2" port="9042"/>
<!--3-->
<ColumnMapping name="id"
pattern="%uuid{TIME}"
columnType="java.util.UUID"/>
<ColumnMapping name="timestamp" columnType="java.util.Date"/>
<ColumnMapping name="level" pattern="%level"/>
<ColumnMapping name="marker" pattern="%marker"/>
<ColumnMapping name="logger" pattern="%logger"/>
<ColumnMapping name="message" pattern="%message"/>
<ColumnMapping name="mdc"
columnType="org.apache.logging.log4j.spi.ThreadContextMap"/>
<ColumnMapping name="ndc"
columnType="org.apache.logging.log4j.spi.ThreadContextStack"/>
</Cassandra>
<!-- end::appender[] -->
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="CASSANDRA"/>
</Root>
</Loggers>
</Configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Configuration:
Appenders:
# tag::appender[]
Cassandra:
name: "CASSANDRA"
clusterName: "test-cluster"
keyspace: "test"
table: "logs"
# <1>
bufferSize: 10
batched: true
# <2>
SocketAddress:
- host: "server1"
port: "9042"
- host: "server2"
port: "9042"
# <3>
ColumnMapping:
- name: "id"
pattern: "%uuid{TIME}"
columnType: "java.util.UUID"
- name: "timestamp"
columnType: "java.util.Date"
- name: "level"
pattern: "%level"
- name: "marker"
pattern: "%marker"
- name: "logger"
pattern: "%logger"
- name: "message"
pattern: "%message"
- name: "mdc"
columnType: "org.apache.logging.log4j.spi.ThreadContextMap"
- name: "ndc"
columnType: "org.apache.logging.log4j.spi.ThreadContextStack"
# end::appender[]
Loggers:
Root:
level: "INFO"
AppenderRef:
ref: "CASSANDRA"
Loading