Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Log Hibernate Info Separately  RSS feed

 
chicha sonu
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am Using Jboss 7.1 with Spring 4 and Hibernate4.
When i start the server i see many logs related to org.hibernate.tool.hbm2ddl and org.springframework.web.servlet.

How can i use log4j to redirect these logs to separate log file instead of Server Log.Can some one provide a working example

Thanks in Advance
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you share your log4j config. I'm guessing you have all logs going to console thus ending up in your Server log...
 
chicha sonu
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
log4j.level.org.springframework.web=INFO
log4j.level.org.hibernate=info, stdout, R

Sorry for the Late Reply
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chicha, you can create a file appender and select that appender for the hibernate and spring packages. If you are not familiar with log4j, I recommend you read the docs first. An example of configuring different appenders for different packages can be found here...
 
chicha sonu
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for Reply
HI

log4j.rootCategory=INFO
log4j.logger.org.hibernate=INFO,FIRST_APPENDER
log4j.logger.FIRST_APPENDER=INFO,FIRST_APPENDER
log4j.appender.FIRST_APPENDER=org.apache.log4j.RollingFileAppender
log4j.appender.FIRST_APPENDER.maxFileSize=10MB
log4j.appender.FIRST_APPENDER.MaxBackupIndex=2
log4j.appender.FIRST_APPENDER.layout=org.apache.log4j.PatternLayout
log4j.appender.FIRST_APPENDER.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x(%F:%L) - %m%n
log4j.appender.FIRST_APPENDER.File=G:/first.log

it still Didnt Work
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that your complete properties file? I don't see console appender so you removed it completely? Also when you say it didn't work can you add more details i.e. what happened, do you still see all logs in server.log, is the first.log file not created at all etc...
 
chicha sonu
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first.log has been created..but not redirecting hibernate logs to first.log.
Its still written in server.log
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This line in your config is useless log4j.logger.FIRST_APPENDER=INFO,FIRST_APPENDER . Apart from that everything else looks fine to me. Can you change the rootLogger to use FIRST_APPENDER and see if it works. Maybe your log4j.properties file is not being read...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!