Skip to content

Custom Log4J2 Appender to store messages in ClickHouse DB

License

Notifications You must be signed in to change notification settings

emelyanovkr/ClickHouseAppender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClickHouseAppender

This is a custom Log4j 2 appender that sends LOGGER messages to a clickhouse database in a specified table in JSON format. Table must have 2 columns:

CREATE TABLE log_table (
	timestamp DateTime PRIMARY KEY,
	log String
	) Engine = MergeTree()

All messages are stored in the buffer. Log messages will be flushed straight to the ClickHouse DB after one of the conditions:

For acquiring a connection to the ClickHouse DB used a JavaClient API (ClickHouse Java API).

Configuring example

        <ClickHouseAppender name="ClickHouseAppender" ignoreExceptions="false"
                            bufferSize="8192"
                            flushTimeoutSec="5"
                            tableName="log_table">

            <ConnectionSettings HOST=""
                                PORT=""
                                USERNAME=""
                                PASSWORD=""
                                DATABASE="log_db"
                                SSL="true" --> must be true for a ClickHouse Connection
                                SOCKET_TIMEOUT="300000"
            />

Releases

No releases published

Packages

No packages published

Languages