在Oracle中进行logback日志记录会导致方言错误 [英] logback logging in oracle causes dialect error

查看:227
本文介绍了在Oracle中进行logback日志记录会导致方言错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用slf4jlogback设置了数据库日志记录.我在postgresqlsqlite上使用了此配置,没有任何问题

I set up database logging with slf4j and logback. I use this configuration with postgresql and sqlite without any problem

<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
    <connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
        <dataSource class="com.zaxxer.hikari.HikariDataSource">
            <driverClassName>org.postgresql.Driver</driverClassName><!-- org.sqlite.JDBC-->
            <jdbcUrl>jdbc.postgresql://host:port/db_name</jdbcUrl><!-- jdbc:sqlite:local/dir/path/db_name.db-->
            <username>username</username>
            <password>password</password>
        </dataSource>
    </connectionSource>
</appender>

现在我想将所有这些日志发送到 oracle db ,所以我分别更改了配置文件

Now I want to send all these logs to oracle db so I changed the config file respectively

<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
    <connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
        <dataSource class="com.zaxxer.hikari.HikariDataSource">
            <driverClassName>oracle.jdbc.driver.OracleDriver</driverClassName>
            <jdbcUrl>jdbc:oracle:thin:blabal@x.x.x.x:port:oraserv</jdbcUrl>
            <username>user</username>
            <password>pass</password>
        </dataSource>
    </connectionSource>
    <sqlDialect class="ch.qos.logback.core.db.dialect.OracleDialect" />
</appender>

但是我遇到了这个错误

15:45:05,832 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@25:76 - no applicable action for [sqlDialect], current ElementPath is [[configuration][appender][sqlDialect]]
15:45:05,837 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@26:16 - 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

我认为通过xml配置方言可以解决问题,但没有任何改变. 您能给我一些建议使其与oracle一起使用吗?

I thought dialect configuration through xml would solve the problem, but nothing changed. Can you give me some advice to make it work with oracle?

推荐答案

我在Mysql中遇到了类似的问题.最终我明白了.我不知道对您有什么帮助,但这是我的配置(常规)

I had similar issues with Mysql. Eventually I figured it out. I don't know if it is any help for you but here is my configuration (groovy)

appender('DB', DBAppender) {
  connectionSource(DataSourceConnectionSource) {
    dataSource(MysqlDataSource) {
      url = "jdbc:mysql://127.0.0.1:3306/ts-mtt"
    }
    user = "root"
    password = ""
  }
} 

不应添加sqlDialect.您还可以看到,用户名和密码是connectionSource的属性.希望对您有所帮助.

The sqlDialect should not be added. Also as you see user and password are properties of a connectionSource. I hope it is any help.

这篇关于在Oracle中进行logback日志记录会导致方言错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆