[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:59:37 CET 2014


Hello again, I found out that the configuration actually logged to the 
database, causing the performance decrease. The filter wasn't working as 
expected, because I didn't set the "onMatch" and "onMismatch" tags. Here's 
the working solution:

        <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
                <evaluator 
class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
                        <marker>LOGDATABASE</marker>
                </evaluator>
                <onMatch>ACCEPT</onMatch>
                <onMismatch>DENY</onMismatch>
        </filter>

Shouldn't this be default instead of NEUTRAL for both onMatch and 
onMismatch?

Best regards,

Simon Erhardt



From:   Simon.Erhardt at befine-solutions.com
To:     logback-user at qos.ch
Date:   31.10.2014 07:41
Subject:        [logback-user] Why does DBAppender slow down logging 
although it     has a non-matching filter?
Sent by:        "Logback-user" <logback-user-bounces at qos.ch>



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_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20141031/a17b2e3a/attachment.html>


More information about the Logback-user mailing list