File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Need help with log4j logging tool to log into database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Need help with log4j logging tool to log into database" Watch "Need help with log4j logging tool to log into database" New topic
Author

Need help with log4j logging tool to log into database

Ravi Singh
Greenhorn

Joined: Sep 17, 2007
Posts: 4
Hi,

I need help with log4j logging tool (org.apache.log4j.*) to log into database using JDBCAppender. Have look at my logger code and corresponding log4j.properties file stated below. I'm running this program using Eclipse IDE and it's giving me the following error (in bold) at the end:

log4j: Parsing for [root] with value=[debug, stdout, Roll, CRSDBAPPENDER].
log4j: Level token is [debug].
log4j: Category root set to DEBUG
log4j: Parsing appender named "stdout".
log4j: Parsing layout options for "stdout".
log4j: Setting property [conversionPattern] to [%x %d{HH:mm:ss,SSS} %5p [%t] (%c:%-4L %M) - %m%n].
log4j: End of parsing for "stdout".
log4j: Parsed "stdout" options.
log4j: Parsing appender named "Roll".
log4j: Parsing layout options for "Roll".
log4j: Setting property [conversionPattern] to [%x %d{yyyy.MM.dd HH:mm:ss,SSS} %5p [%t] (%c:%-4L %M) - %m%n].
log4j: End of parsing for "Roll".
log4j: Setting property [file] to [HelloWorld.log].
log4j: Setting property [maxBackupIndex] to [10].
log4j: Setting property [maxFileSize] to [20KB].
log4j: setFile called: HelloWorld.log, true
log4j: setFile ended
log4j: Parsed "Roll" options.
log4j: Parsing appender named "CRSDBAPPENDER".

Can't find class HelloWorld







Here is the directory structure of my program. My log4j.properties file and HelloWorld.class file are residing in folder HelloWorld\bin.

HelloWorld\bin
HelloWorld\lib
HelloWorld\src

Please note - The same program works fine for console and file appender when I comment the database appender part in my properties file.
Thanks
Ravinder
[ September 17, 2007: Message edited by: Ulf Dittmer ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41106
    
  45
Hello "RSG RSG"-

Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, it sounds like the classpath is not set correctly. Does it include the HelloWorld\bin directory? Does the program run at all?


Ping & DNS - my free Android networking tools app
Ravi Singh
Greenhorn

Joined: Sep 17, 2007
Posts: 4
Yes the program works fine if I remove (or comment) the database appender settings in properties file.
Ravi Singh
Greenhorn

Joined: Sep 17, 2007
Posts: 4
I've got my program working now. I was using the wrong version of log4j library in my build path. Thanks for your pointer, Ulf...

Cheers!
Ravi Singh
 
 
subject: Need help with log4j logging tool to log into database
 
Similar Threads
remove log4j appender from an API
log4j & log4j.xml
A Log4j Stumper, can't get logs in the right place.
Capture logs to file via log4j.xml
Using JDBCAppender for older versions of JDK