[logback-user] Using DBAppender with an unreliable database connection

Ceki Gülcü ceki at qos.ch
Tue Oct 7 22:47:09 CEST 2014


I think this merits a jira. Could you create it please?

On 10/7/2014 21:10, Paul Krause wrote:
> We are using logback 1.1.2 with slf4j 1.7.7.   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.
>
> Is there a way to detect this and retry the connection, or a way for the application to check DBAppender's state and tell it to reconnect if needed? This is only a problem for logging, because by the time the application tries to connect, the database is up and ready to receive connections.
>
> 12:11:11,593 |-WARN in ch.qos.logback.core.db.DataSourceConnectionSource at 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)
>
>
> Thanks,
> Paul Krause

>


More information about the Logback-user mailing list