apache / apache/logging-log4j2

Rationalize the usage of `Connection` in the JDBC appender

Open
#1,916 2 comments 0 reactions 0 assignees View on GitHub
appenders appenders:JDBC
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
1d 20h
Merged PRs (30d)
30

Description

The JDBC appender takes a very conservative approach to SQL connection sharing:

1. as most appenders, each `append` call is synchronized,
2. each event (or batch of events) is logged using a different `Connection` object, which is closed at the end of the call,
3. to prevent the high performance hit from creating many `Connection`s, users are advised to use a connection pool like DBCP2.

This approach has many disadvantages:

- it does not profit from the connection pool, since at any time at **most** one connection will be borrowed from the pool,
- on the other hand users that use `DriverManager` get a performance hit, even if 1. ensures that no `Connection` object will be used concurrently on multiple threads.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the JDBC appender and reading its append and connection-lifecycle logic. Investigate the stated trade-offs between synchronized appends, connection pooling, and DriverManager usage; done should establish a decided connection-sharing approach and verify its behavior under the described usage patterns.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.