Logback - C3P0 和 HSQLDB
我正在尝试让 LogBack 将 HSQLDB 与 C3P0 一起使用。鉴于我当前的环境,我目前坚持使用此配置。我对 Log4J 代码进行了大量投资,并且还需要使用 SLF4J Log4J 适配器。当我尝试一个简单的日志记录程序时,它陷入了记录器配置阶段。这是我的 logback.xml
:
<configuration>
<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
<connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
<dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">
<driverClass>org.hsqldb.jdbcDriver</driverClass>
<jdbcUrl>jdbc:hsqldb:hsql://localhost:9001/mid_logs</jdbcUrl>
<user>sa</user>
<password>sa</password>
</dataSource>
</connectionSource>
</appender>
<root level="debug">
<appender-ref ref="DB" />
</root>
</configuration>
我的类路径是:
bin/.;lib/hsqldb.jar;lib/log4j-over-slf4j-1.5.8.jar;lib/logback-access-0.9.17.jar;lib/logback-classic-0.9.17.jar;lib/logback-core-0.9.17.jar;lib/slf4j-api-1.5.8.jar;lib/slf4j-log4j12-1.5.8.jar;lib/c3p0-0.9.1.2.jar
这是我的代码片段:
System.out.println("Starting");
Logger logger = Logger.getLogger(TestLogging.class);
System.out.println("got Logger");
“Starting”出现在控制台输出中,但没有其他内容。
任何帮助将不胜感激!
I'm trying to get LogBack to use a HSQLDB with C3P0. I'm stuck with this configuration at the moment given my current environment. I have a large investment with Log4J code and will also need to use the SLF4J Log4J Adapter. When I try a simple logging program it's getting stuck in the logger configuration stage. Here is my logback.xml
:
<configuration>
<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
<connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
<dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">
<driverClass>org.hsqldb.jdbcDriver</driverClass>
<jdbcUrl>jdbc:hsqldb:hsql://localhost:9001/mid_logs</jdbcUrl>
<user>sa</user>
<password>sa</password>
</dataSource>
</connectionSource>
</appender>
<root level="debug">
<appender-ref ref="DB" />
</root>
</configuration>
My classpath is:
bin/.;lib/hsqldb.jar;lib/log4j-over-slf4j-1.5.8.jar;lib/logback-access-0.9.17.jar;lib/logback-classic-0.9.17.jar;lib/logback-core-0.9.17.jar;lib/slf4j-api-1.5.8.jar;lib/slf4j-log4j12-1.5.8.jar;lib/c3p0-0.9.1.2.jar
Here is a snippet of my code:
System.out.println("Starting");
Logger logger = Logger.getLogger(TestLogging.class);
System.out.println("got Logger");
The 'Starting' appears in the console output, but nothing else.
Any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您收到什么状态消息?您可以通过在配置文件中添加以下行来列出它们:
由于上面的配置文件格式不正确,因此难以阅读。
What status messages are you getting? You can have them listed by adding the following line in your configuraton file:
Since your configuration file above is not nicely formatted, making it hard to read.
我将
StatusListener
添加到logback.xml
文件中,这是输出:如果我执行“
netstat -a -n
”,我会看到连接到数据库,但没有活动。I added the
StatusListener
to thelogback.xml
file and here is the output:If I do a "
netstat -a -n
" I see connections to the database, but no activity.