Note that there are some explanatory texts on larger screens.

plurals
  1. POAsynchronous DBAppender with logback
    primarykey
    data
    text
    <p>I'm working on an application that uses logback for logging. I used the logback DBAppender to insert logs into DB.</p> <p>All worked great for me and i was able to insert and see the logs into the Database.</p> <p>I did some testing with 200 logging line of code and measured the time consumption for those 200 logs and got 10 milliseconds without using the DBAppender. When i added the DBAppender i got around 2700 milliseconds.</p> <p>I tried to use the <code>ch.qos.logback.classic.AsyncAppender</code> with no luck making it work asynchronously. I always get 0 results inserted into my database.</p> <p>My configuration looks like the below:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;configuration debug="true"&gt; &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt; &lt;!-- encoders are by default assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder --&gt; &lt;encoder&gt; &lt;pattern&gt;%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n&lt;/pattern&gt; &lt;/encoder&gt; &lt;/appender&gt; &lt;appender name="DBAppPostgreSQL" class="ch.qos.logback.classic.db.DBAppender"&gt; &lt;connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource"&gt; &lt;dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource"&gt; &lt;driverClass&gt;org.postgresql.Driver&lt;/driverClass&gt; &lt;url&gt;jdbc:postgresql://127.0.0.1:5678/DB&lt;/url&gt; &lt;user&gt;YYYYY&lt;/user&gt; &lt;password&gt;XXX&lt;/password&gt; &lt;/dataSource&gt; &lt;/connectionSource&gt; &lt;sqlDialect class="ch.qos.logback.core.db.dialect.PostgreSQLDialect" /&gt; &lt;insertHeaders&gt;true&lt;/insertHeaders&gt; &lt;/appender&gt; &lt;appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender"&gt; &lt;appender-ref ref="DBAppPostgreSQL" /&gt; &lt;includeCallerData&gt;true&lt;/includeCallerData&gt; &lt;/appender&gt; &lt;root level="debug"&gt; &lt;appender-ref ref="ASYNC" /&gt; &lt;appender-ref ref="STDOUT" /&gt; &lt;/root&gt; &lt;/configuration&gt; </code></pre> <p>Is there anything missing with my configuration? Or is there any other way to make it insert logs into DB faster?</p> <p>Note that i'm using postgreSQL</p> <p>Thanks,</p> <p><strong>EDITED:</strong></p> <p>I'm using logback 1.0.11 over slf4j 1.7.5. Also i'm using postgresql 8.0.325.</p> <p>The logback's internal status is:</p> <pre><code>10:52:09,693 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy] 10:52:09,693 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml] 10:52:09,693 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/D:/BOOM/BoomFinancial/BoomMonitoringTesting/bin/logback.xml] 10:52:09,759 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 10:52:09,761 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT] 10:52:09,771 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property 10:52:09,800 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.db.DBAppender] 10:52:09,803 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DBAppPostgreSQL] 10:52:09,809 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@14:75 - no applicable action for [dataSource], current pattern is [[configuration][appender][connectionSource][dataSource]] 10:52:09,866 |-INFO in ch.qos.logback.core.db.dialect.DBUtil@30e34726 - Could not call supportsGetGeneratedKeys method. This may be recoverable 10:52:09,866 |-INFO in ch.qos.logback.core.db.DriverManagerConnectionSource@195428dd - Driver name=PostgreSQL Native Driver 10:52:09,866 |-INFO in ch.qos.logback.core.db.DriverManagerConnectionSource@195428dd - Driver version=PostgreSQL 8.0 JDBC2 with NO SSL (build 325) 10:52:09,866 |-INFO in ch.qos.logback.core.db.DriverManagerConnectionSource@195428dd - supportsGetGeneratedKeys=false 10:52:09,867 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@21:77 - no applicable action for [sqlDialect], current pattern is [[configuration][appender][sqlDialect]] 10:52:09,868 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@22:21 - no applicable action for [insertHeaders], current pattern is [[configuration][appender][insertHeaders]] 10:52:09,870 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.AsyncAppender] 10:52:09,872 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [ASYNC] 10:52:09,872 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DBAppPostgreSQL] to ch.qos.logback.classic.AsyncAppender[ASYNC] 10:52:09,872 |-INFO in ch.qos.logback.classic.AsyncAppender[ASYNC] - Attaching appender named [DBAppPostgreSQL] to AsyncAppender. 10:52:09,874 |-INFO in ch.qos.logback.classic.AsyncAppender[ASYNC] - Setting discardingThreshold to 51 10:52:09,874 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG 10:52:09,875 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [ASYNC] to Logger[ROOT] 10:52:09,875 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT] 10:52:09,875 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 10:52:09,876 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@23e0512a - Registering current configuration as safe fallback point </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload