Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1022

Make DBAppender work with unreliable database connection

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 1.1.2
    • logback-classic
    • logback 1.1.2 with slf4j 1.7.7, using DBAppender to log to a SQL Server database from a Spring webapp under Tomcat via ch.qos.logback.core.db.DataSourceConnectionSource

    Description

      We have configured DBAppender to log to a SQL Server database from a Spring webapp under Tomcat using ch.qos.logback.core.db.DataSourceConnectionSource. This works fine, except that when the host reboots (this is Windows, after all), Tomcat restarts faster than SQL Server does, so when DataSourceConnectionSource is first started, it fails to connect to the database.

      There should be a way to detect this and retry the connection., Alternately, there should be a way for the application to check DBAppender's state and tell it to reconnect if needed.

      12:11:11,593 |-WARN in ch.qos.logback.core.db.DataSourceConnectionSource@134c00a9 - Could not discover the dialect to use. java.sql.SQLException: Cannot open database requested by the login. The login failed.
      at java.sql.SQLException: Cannot open database requested by the login. The login failed.
      at at ch.qos.logback.core.db.DataSourceConnectionSource.getConnection(DataSourceConnectionSource.java:63)
      at at ch.qos.logback.core.db.ConnectionSourceBase.discoverConnectionProperties(ConnectionSourceBase.java:48)
      at at ch.qos.logback.core.db.DataSourceConnectionSource.start(DataSourceConnectionSource.java:44)
      at at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:167)
      at at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317)
      at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196)
      at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)
      at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
      at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149)
      at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)
      at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99)
      at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:49)
      at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
      at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
      at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
      at at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
      at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:129)
      at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
      at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:302)
      at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:276)
      at at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
      at at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
      at at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:274)
      at at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:282)

      Attachments

        Activity

          People

            logback-dev Logback dev list
            paulkrause88 Paul Krause
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: