views:

376

answers:

2

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 configuration of the logger. 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> <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!

A: 

What status messages are you getting? You can have them listed by adding the following line in your configuraton file:

<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />

Since your configuration file above is not nicely formatted, making it hard to read.

Ceki
A: 

I added the statusListener to the logback.xml file and here is the output:

07:45:12,816 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.db.DBAppender] 07:45:12,832 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DB] 07:45:12,848 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [connectionSource] on top of the object stack. 07:45:13,129 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [dataSource] on top of the object stack.

If I do a "netstat -a -n" I see connections to the database, but no activity.

Frank Mundt