[ 
https://issues.apache.org/jira/browse/LOG4J2-407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13827883#comment-13827883
 ] 

Michael Kloster commented on LOG4J2-407:
----------------------------------------

Another approach to this problem would be to take advantage of the connection 
pool. At this point, you can set up a connection pool (via the JDBC Datasource) 
for the logger, but it is just used once to get a single connection that is 
held by the logger and never returned to the pool. 

If the logger requested a connection from the pool and returned it after each 
use, the connection pool can be configured to check connection validity (or 
not) depending on the application need for performance. If the pool can't give 
the logger a valid connection, then you can throw an exception without further 
logic. 

I have never benchmarked the processes of taking/returning a connection from a 
pool but I've always imagined it to be about as fast as taking an object from a 
dictionary. Is that not the case?

One issue I see with this suggestion is it makes an assumption that a pool is 
configured. Maybe this could be overcome with a "isPooled" flag. Then the 
appender could supply its own 'poor man's' version of a pool like it does now 
if the connection is not marked as pooled.

> JDBCAppender cannot recover from loss of database connectivity
> --------------------------------------------------------------
>
>                 Key: LOG4J2-407
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-407
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.0-beta9
>            Reporter: Michael Kloster
>            Assignee: Nick Williams
>
> The JDBCAppender holds a single database connection for all its logging. If 
> that database connection is closed, it does not attempt to make a new 
> connection.
> Many connection pools automatically close connections after a certain amount 
> of inactivity. (This can be worked around by properly configuring a pool).
> Database connectivity issues are also common enough that a long running 
> application may experience temporary network issues. When the network comes 
> back online, the logging will not resume.
> I've been meaning to submit a patch for this, but I haven't gotten to it. 
> Since I saw that you are looking to come out of beta soon, I thought I would 
> log this issue in case someone else has time to write the patch before I get 
> to it.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to