• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Log Hibernate Info Separately

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 9697
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9697
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9697
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9697
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic