• 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

Configuring log4j in JSF

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm new to using JSF and am having problems configuring log4j.
In the past I have done the log4j configuration in a servlet which I have set as load-on-startup. Is there an equivalent method of configuration in JSF or is there a better way of doing it? I tried defining a bean with application scope to do the configuration but it's never loaded.
I can't help feeling I'm missing something obvious, but I thought I would ask anyway.

Thanks,

John
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am Not that good that either but I think there shouldn't be anything different for Configure Log4J in JSF Application. You need to add same entry in Web.xml
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Configuring

log4.properties should go into Web-Inf/classes.
It means that if you are using eclipse or ant you have to make sure that
it goes there after you compile the classes.

In eclipse: Put log4j.properties in src. If you are using WTP or
MyEclipse or something like it log4j.properties gets copied into Web-Inf/classes after eclipse builds your web project.

2) Using

Put the log4j**.jar in Web-Inf/lib

Make sure you don't put commons-logging in there!!!

After this you can just define a logger in each class the way it is
usually done:

public static final Logger
logger = Logger.gerLogger(this.getClass().getName());

In log4j.properties set the level for the root and al the other classes from which you need logging messages.

That should do it. At least it is the configuration we are using in our JSF project. And it works.

[ October 07, 2006: Message edited by: Nomunbilegt Batsukh ]
[ October 07, 2006: Message edited by: Nomunbilegt Batsukh ]
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSF isn't magic. The Faces Servlet doesn't restrict your ability to do non-JSF things in the same webapp.

If you need a startup servlet, you can still provide one and it won't interfere with JSF. In fact, you can migrate Struts apps by keeping both the FacesServlet and Struts servlet both in the same app.

I'm not sure, but I think that the MyFaces JSF implementation cranks up the apache commons logging and thence Log4J, so you may not need a separate servlet to start up Log4J.

This may help:

http://wiki.apache.org/myfaces/LoggingSettings
 
reply
    Bookmark Topic Watch Topic
  • New Topic