File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Log sql to LOG4J Appender Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Log sql to LOG4J Appender" Watch "Log sql to LOG4J Appender" New topic
Author

Log sql to LOG4J Appender

vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
I am trying to output the sql which hibernate generates in my application to my log4j appender as follows:

1. I am not seeing any output in test.log from hibernate
2. In system.out log I am not seeing the actual parameter value:

I am using Spring. My appContext.xml is as follows
ntumba lobo
Ranch Hand

Joined: Oct 21, 2008
Posts: 180
you need to make sure that either your file is named log4j.ml and is present at the root of your classpath with log4j jar in the classpath as well.
Or if you name it differently you need to load the file with a configurer caling your specific name


SCJP 5 , SCWCD 5, SCEA 5
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
ntumba lobo wrote:you need to make sure that either your file is named log4j.ml and is present at the root of your classpath with log4j jar in the classpath as well.
Or if you name it differently you need to load the file with a configurer caling your specific name


My application is able to output to the test.log file. Its just the hibernate output which is not being displayed in test.log
ntumba lobo
Ranch Hand

Joined: Oct 21, 2008
Posts: 180
Then try specifying the log4j appender in both your hibernate loggers


vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
already tried that - no luck. according to log4j docs loggers inherit from the root so dont need to specify appender hence the reason why i removed it
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
any ideas??? i am using spring 2.5.6, log4j 1.2.16, hibernate 3.2.6ga and Websphere App Server 7
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Log sql to LOG4J Appender