Meaningless Drivel is fun!*
The moose likes Other Open Source Projects and the fly likes problem in using log4j JDBCAppender Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "problem in using log4j JDBCAppender" Watch "problem in using log4j JDBCAppender" New topic
Author

problem in using log4j JDBCAppender

Raghavendra Rao
Greenhorn

Joined: Apr 13, 2004
Posts: 9
Hi all!
i have placed the classes111 and classes12.jar files in web-inf/lib folder and used a servlet which reads this properties file and log the statement to database.i am not able to log the statements in to the database ....i have use the following properties file:
log4j.appender.R=org.apache.log4j.jdbc.JDBCAppender
log4j.rootLogger=debug, R
log4j.appender.R.Driver=oracle.jdbc.driver.OracleDriver
log4j.appender.R.URL = jdbc racle:thin@192.168.0.200:1521:itsr
log4j.appender.R.user=hpabopa1
log4j.appender.R.password=hpa
log4j.appender.R.sql=INSERT INTO jdbctest(message) VALUES ('%d - %c - %p - %m')
#
# These defines the layout to be used.
#
log4j.appender.R.layout=org.apache.log4j.PatternLayout
can anyonle please help me....

thanks in advance..
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Moving to Other Open Source Projects forum.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
what is the error / you dont see anything at all?.
log4j.properties is located in the web-inf/classes folder?
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Why dont u write a simple test.jsp that retreives the logger and just
prints something to the table.
Yes log4j.jar and classes12.zip s'd be in web-inf/lib folder
Put log4j.properties in web-inf/classes folder.
Just invoke the test jsp.
If you are using tomcat and if something is wrong you s'd see an error displayed on tomcat console.
We might be able to help after taking a look at the error.
David Yutzy
tumbleweed and gunslinger
Ranch Hand

Joined: Jun 29, 2001
Posts: 192
I'm trying the same thing, here is what I have thus far, the code, exceptions, etc.
Using: Tomcat: v4.1.29; log4j v1.2.7
log4j.properties

I get the collowing exception when Tomcat starts up:
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by David Yutzy:
I'm trying the same thing, here is what I have thus far, the code, exceptions, etc.

And you have the jar file that contains the driver class in web-inf/lib folder?
I guess you must be having log4j.jar there alogn with other required libraries. (I dont know the SQL Server database driver name)
David Yutzy
tumbleweed and gunslinger
Ranch Hand

Joined: Jun 29, 2001
Posts: 192
Yes, I can use SQL Server in the web application just fine.
One thing I notice is that it appears to be loading the log4j settings during the Tomcat start-up rather than the WebApp start-up process.
When I set Log4J to debug to the console, I usually get the Tomcat stuff scroll by, then it loads the webapp stuff, showing it in debug mode.
When I change it to the DB version of log4j.properties, I see about 3 lines of Tomcat, then the exception I previously posted, then it loads the webapp.
I wonder if I placed the DB .jar driver files in the Tomcat/lib if that would make a difference?
Rahul N Bhardwaj
Greenhorn

Joined: May 24, 2004
Posts: 1
hi all,
i m tryng to use log4j to insert the data into database. i want to insert the SQLs into the database so that we can check them in case of any error. can anyone pl. tell me how to go about it. i m new to log4j, so need help.
pl. mail me at bharahul@yahoo.com
thnx
Rahul N B
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in using log4j JDBCAppender