• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

J2EE & log4j

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I don't really know where exactly to post so sorry if I don't do it in the right place.
I'm trying to use log4j in my j2ee application (EJB + JSP + Servlets + Hibernate). There are some different web applications and I would like to split the log in different files. I use a socket appender to the localhost with this properties file

log4j.rootLogger=DEBUG, shark
log4j.logger.org.hibernate=ERROR
log4j.additivity.org.hibernate.SQL=false

log4j.appender.shark=org.apache.log4j.net.SocketAppender
log4j.appender.shark.Port=6000
log4j.appender.shark.RemoteHost=localhost


and the server configuration file


log4j.rootLogger=DEBUG, shark
log4j.threshold=INFO
log4j.appender.shark=org.apache.log4j.FileAppender
log4j.appender.shark.File=shark-com.redamm.shark.log
log4j.appender.shark.layout=org.apache.log4j.PatternLayout
log4j.appender.shark.layout.ConversionPattern=%p %t - %l %F %M %c - %m%n



I use a init Servlet for initialize the log4j.properties and I run the server from the command line. The initialization goes on properly but without a specific reason I get an EOFException The exception pops up in many different moments and I can't understand what exactly is making to close the connection. I've tried to initialize the log4j.properties in the server also and the problem persists (I got the exception only starting the application server). I've tried a dummy web project which only loads the init Servlet and logs something, and the same problem, conects ok but it looses the connection suddenly including when I only run the web project.

I use Netbeans 6 and Glassfish 2 running in a Mac computer.

I wonder what I'm missing ... any idea???
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can tell you the log4j.properties contents and where you have to copy it. So you just try it by putting in the respective folder for me its working.

your log4j.properties file

# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!#
For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.

log4j.rootLogger=INFO, stdout, logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=c:/log/strhib.log
log4j.appender.logfile.MaxFileSize=512KB
# Keep three backup files.
log4j.appender.logfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n


//**********************************

NB:log4j.appender.logfile.File=c:/log/strhib.log
this is the path and the log file name it will automatically create by the application.

just put the log4j.properties file inside you src folder and classes folder.

Definitely it will work for you.
No need to worry.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic