[logback-user] DbAppender does not write log messages to Oracle DB
Sumanth Donthi
thetallman63 at yahoo.com
Thu Jan 13 08:19:59 CET 2011
Do not see records logging into Oracle 11.1 tables using logback.
The three tables( logging_event, logging_event_exception,
logging_event_exception) exist in Oracle DB.
Note: I've tried replacing ojdbc6.jar and ojdbc5.jar logback still the result is
same. No records in DB
---------------------------------DBlogback.xml-----------------------------------
<configuration debug="true" scan="true" scanPeriod="3 seconds">
<property name="hostName" value="localhost"/>
<property name="port" value="1521"/>
<property name="sid" value="test"/>
<property name="user" value="admin"/>
<property name="password" value="admin"/>
<appender name="DB2" class="ch.qos.logback.classic.db.DBAppender">
<connectionSource
class="ch.qos.logback.core.db.DriverManagerConnectionSource">
<driverClass>oracle.jdbc.driver.OracleDriver</driverClass>
<url>jdbc:oracle:thin:@${hostName}:${port}:${sid}</url>
<user>${user}</user>
<password>${password}</password>
</connectionSource>
</appender>
<!--
<appender name="DB3" class="ch.qos.logback.classic.db.DBAppender">
<connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
<dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">
<driverClass>oracle.jdbc.driver.OracleDriver</driverClass>
<jdbcUrl>jdbc:oracle:thin:@${hostName}:${port}:${sid}</jdbcUrl>
<user>${user}</user>
<password>${password}</password>
</dataSource>
</connectionSource>
</appender>
-->
<root level="TRACE">
<appender-ref ref="DB2" />
</root>
</configuration>
---------------------------------------------------------------------------------------
The following log output shows no errors tried both DB2 and DB3 appenders the
result is same. Log records won't get inserted into none of the tables.
22:15:44,015 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT
find resource [logback.groovy]
22:15:44,015 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT
find resource [logback-test.xml]
22:15:44,015 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT
find resource [logback.xml]
22:15:44,015 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Setting
up default configuration.
22:15:44,218 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction -
Setting ReconfigureOnChangeFilter scanning period to 3 seconds
22:15:44,218 |-INFO in
ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter at 2ab32ab3 - Will scan for
changes in file [C:\workspace\LogTest\com\test\DBlogback.xml] every 3 seconds.
22:15:44,218 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction -
Adding ReconfigureOnChangeFilter as a turbo filter
22:15:44,234 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About
to instantiate appender of type [ch.qos.logback.classic.db.DBAppender]
22:15:44,234 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming
appender as [DB2]
22:15:47,593 |-INFO in
ch.qos.logback.core.db.DriverManagerConnectionSource at 6b746b74 - Driver
name=Oracle JDBC driver
22:15:47,593 |-INFO in
ch.qos.logback.core.db.DriverManagerConnectionSource at 6b746b74 - Driver
version=11.1.0.7.0-Production
22:15:47,593 |-INFO in
ch.qos.logback.core.db.DriverManagerConnectionSource at 6b746b74 -
supportsGetGeneratedKeys=true
22:15:47,609 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction -
Setting level of ROOT logger to TRACE
22:15:47,609 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction -
Attaching appender named [DB2] to Logger[ROOT]
22:15:47,609 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction -
End of configuration.
----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------
The following jars are in the classpath of the sample project
slf4j-api-1.6.1.jar
logback-core-0.9.27.jar
logback-classic-0.9.27.jar
logback-access-0.9.27.jar
commons-compiler.jar
commons-compiler-jdk.jar
janino.jar
ojdbc6.jar
Oracle version 11.1
-----------------------------------------------------------------------------------------
package com.test
import java.net.URL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.util.Loader;
import ch.qos.logback.core.util.StatusPrinter;
public class LogTest
{
public static void main(String[] args)
{
Logger logger = LoggerFactory.getLogger("LogTest");
try
{
configureViaXML_File();
logger.info("Testing Status Text {}, {}","123", "test");
logger.debug("Test Parameterized {} {} {} {} {}",new Object[] {1, 2,3,4,5});
}
catch(Exception ex)
{
logger.error("Exception in this LogTest message.",ex);
ex.printStackTrace();
}
}
static void configureViaXML_File() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.stop();
URL url = Loader.getResourceBySelfClassLoader("com/test/DBlogback.xml");
configurator.doConfigure(url);
} catch (JoranException je) {
StatusPrinter.print(lc);
}
}
}
----------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/logback-user/attachments/20110112/fbce7783/attachment-0001.html>
More information about the Logback-user
mailing list