播放重启时出现DBappender错误

时间:2014-11-17 15:07:13

标签: playframework-2.0 slf4j logback

我有一个设置,可以将来自某个记录器的消息记录到数据库中。这是我的logger.xml的相关组件:

<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
  <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
    <driverClass>org.postgresql.Driver</driverClass>
    <url>jdbc:postgresql://localhost:5432/logback</url>
    <user>ashishag</user>
    <password>password</password>
  </connectionSource>
</appender>

当我启动播放服务器时,DB appender工作正常。

20:18:05,907 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.db.DBAppender]
20:18:05,913 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DB]
20:18:05,994 |-INFO in ch.qos.logback.core.db.DriverManagerConnectionSource@8d2c5b - Driver name=PostgreSQL Native Driver
20:18:05,994 |-INFO in ch.qos.logback.core.db.DriverManagerConnectionSource@8d2c5b - Driver version=PostgreSQL 9.0 JDBC4 (build 801)
20:18:05,994 |-INFO in ch.qos.logback.core.db.DriverManagerConnectionSource@8d2c5b - supportsGetGeneratedKeys=true

确定驱动程序名称就好了。 但是,当我保存导致播放编译文件并重新启动服务器的文件时,DB appender停止工作。

20:21:29,183 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.db.DBAppender]
20:21:29,183 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DB]
20:21:29,184 |-WARN in ch.qos.logback.core.db.DriverManagerConnectionSource@a80681 - Could not discover the dialect to use. java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/logback
        at java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/logback
        at      at java.sql.DriverManager.getConnection(DriverManager.java:596)
        at      at java.sql.DriverManager.getConnection(DriverManager.java:215)


---snip--
20:21:29,195 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@44:14 - RuntimeException in Action for tag [appender] java.lang.IllegalStateException: DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect
        at java.lang.IllegalStateException: DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect
        at      at ch.qos.logback.core.db.DBAppenderBase.start(DBAppenderBase.java:62)
        at      at ch.qos.logback.classic.db.DBAppender.start(DBAppender.java:92)

看起来它无法加载驱动程序。 (也许这就是为什么不支持getGeneratedKeys的声明)

总结一下: 启动服务器:

  

驱动程序名称= PostgreSQL本机驱动程序

     

驱动程序版本= PostgreSQL 9.0

     

JDBC4(build 801)支持GetGeneratedKeys = true


重启服务器: 声称未找到未找到的方言(未找到驱动程序)和generatedKeys。

有人知道什么是错的吗?

0 个答案:

没有答案