I have the following error when running the sample code below:
log4j:ERROR No appenders could be found for category
(com.mellon.te.logging.test.LogThisTester).
log4j:ERROR Please initialize the log4j system properly.
Any help with getting a sample JDBCAppender class writing messages to a DB
would be greatly appreciated.
Tommy
-----Original Message-----
From: Emricko Thomas E [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 5:22 PM
To: '[EMAIL PROTECTED]'
Subject: JDBCAppender...
Hello -
I am looking for some help with getting the JDBCAppender to work with log4j.
My goal is to have one class to be a 'proof of concept' that I can write a
simple log message to a database (DB2), here is my class:
public class LogThisTester{
static Category MyCat =
Category.getInstance(LogThisTester.class.getName());
public static void main(String[] args) {
// Ensure to have all necessary drivers installed !
try
{
Driver d =
(Driver)(Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance());
DriverManager.registerDriver(d);
System.out.println("DB2 JDBC Database Driver loaded.");
}
catch(Exception e){
System.out.println("DB2 JDBC Database Driver can't be
found.");
e.printStackTrace();
}
// Set the priority which messages have to be logged
MyCat.setPriority(Priority.INFO);
// Configuration with configuration-file
String theFile =
ConfigurationManager.getServiceConfigFilePath("EB0LoggingServices");
PropertyConfigurator.configure(theFile);
MyCat.debug( "Debug" );
}
}
and my property file:
# Declare a appender variable named JDBC
log4j.rootCategory=JDBC
# JDBC is a class of JDBCAppender, which writes messages into a database
log4j.appender.JDBC=com.klopotek.utils.log.JDBCAppender
# 1. Database-options to connect to the database
log4j.appender.JDBC.url=jdbc:db2:foo
log4j.appender.JDBC.username=db2admin
log4j.appender.JDBC.password=password
# 2. Connector-option to specify your own JDBCConnectionHandler
#log4j.appender.JDBC.connector=MyConnectionHandler
# 3. SQL-option to specify a static sql-statement which will be performed
with every occuring message-event
log4j.appender.JDBC.sql=INSERT INTO LOGTEST (id, msg, created_on,
created_by) VALUES (1, @MSG@, sysdate, 'me')
# 4. Table-option to specify one table contained by the database
log4j.appender.JDBC.table=logtest
# 5. Columns-option to describe the important columns of the table (Not
nullable columns are mandatory to describe!)
log4j.appender.JDBC.columns=id_seq~EMPTY id~ID~MyIDHandler
msg~MSG created_on~TIMESTAMP created_by~STATIC~Thomas Emricko
# 6. Layout-options to define the layout of the messages (optional)
log4j.appender.JDBC.layout=org.apache.log4j.PatternLayout
log4j.appender.JDBC.layout.ConversionPattern=%m
# 7. Buffer-option to define the size of the message-event-buffer (optional)
#log4j.appender.JDBC.buffer=1
# 8. Commit-option to define a auto-commitment (optional)
#log4j.appender.JDBC.commit=Y
I am having no luck writing the "Debug" string to my database, and I am not
receiving any errors when I run this class (from VisualAge).
I would greatly appreciate any help!
Tommy
*****************************************************************
DISCLAIMER: The information contained in this e-mail may be confidential
and is intended solely for the use of the named addressee. Access, copying
or re-use of the e-mail or any information contained therein by any other
person is not authorized. If you are not the intended recipient please
notify us immediately by returning the e-mail to the originator.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
*****************************************************************
DISCLAIMER: The information contained in this e-mail may be confidential
and is intended solely for the use of the named addressee. Access, copying
or re-use of the e-mail or any information contained therein by any other
person is not authorized. If you are not the intended recipient please
notify us immediately by returning the e-mail to the originator.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]