[logback-user] Why does DBAppender slow down logging although it has a non-matching filter?

Simon.Erhardt at befine-solutions.com Simon.Erhardt at befine-solutions.com
Fri Oct 31 07:40:58 CET 2014


Hello there, we are using TomEE, SLF4J and Logback. Our aim is to log 
certain logging statements into a database (determined by a marker), in 
addition to the stdout. Here is our logback configuration:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <appender name="STDOUT" 
class="ch.qos.logback.core.ConsoleAppender">
            <encoder>...</encoder>
        </appender>

        <appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
            <connectionSource 
class="ch.qos.logback.core.db.DriverManagerConnectionSource">
                <driverClass>oracle.jdbc.OracleDriver</driverClass>
                <url>...</url>
            </connectionSource>
            <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
                <evaluator 
class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
                    <marker>LOGDATABASE</marker>
                </evaluator>
            </filter>
        </appender>

        <root level="info">
            <appender-ref ref="STDOUT" />
            <appender-ref ref="DB" />
        </root>
    </configuration>

TomEE (which is configured to use SLF4J) takes about 3 times longer to 
startup if the DBAppender is active (14 seconds compared to 4 seconds). 
Although the filtering works and there are no log entries in the database 
for the tomcat startup.
I already know that I could use connection pooling to speed up when it 
actually comes to database logging. But nevertheless the filter should do 
it in this case. My suspicion is that there are connections opened and 
closed during logging, even if the log statement is filtered out. 
Or are there any other ideas why this is so slow?

Best regards,

Simon Erhardt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20141031/a70c2273/attachment.html>


More information about the Logback-user mailing list