Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/emelyanovkr/clickhouseappender

Custom Log4J2 Appender to store messages in ClickHouse DB
https://github.com/emelyanovkr/clickhouseappender

api clickhouse concurrency contribution java javaclient log4j2 log4j2-appender opensource

Last synced: 25 days ago
JSON representation

Custom Log4J2 Appender to store messages in ClickHouse DB

Awesome Lists containing this project

README

        

# 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 DateTime64 PRIMARY KEY,
log String
) Engine = MergeTree()
```

All messages are stored in the [buffer](https://github.com/emelyanovkr/ClickHouseAppender/blob/main/src/main/java/com/clickhouse/appender/manager/LogBufferManager.java#L13C42-L13C56).
Log messages will be flushed straight to the ClickHouse DB after **one of the conditions**:
- timeout;
- buffer size limit exceeded;
- shutdown JVM ([SHUTDOWN-THREAD](https://github.com/emelyanovkr/ClickHouseAppender/blob/main/src/main/java/com/clickhouse/appender/manager/LogBufferManager.java#L53C7-L56C25))

For acquiring a connection to the ClickHouse DB used a JavaClient API ([ClickHouse Java API](https://github.com/ClickHouse/clickhouse-java)).

### Configuring example
```

must be true for a ClickHouse Connection
SOCKET_TIMEOUT="300000"
/>
```