Hi Jeff,

Thanks for responding. I have written a simple Listener class that is loaded at startup by Tomcat, which makes a static logger available to the web-app (both as a static getter and a servlet context param), and I have no problem using it from other areas such as jsp or servlets or non-maverick pojo's. The logger itself is a simple custom jdk1.4 logger (ie not log4j) and uses a very simple formatter. It uses a FileHandler that points to a txt file in WEB-INF. No errors appear to be generated and as far as I'm aware there are no weird classloader issues.

here is the Listener that creates the logger:

public class SiteLogger implements ServletContextListener {
    private static Logger logger;
    public static Logger getLogger() {
        return logger;

    public void contextInitialized(ServletContextEvent e) {
        ServletContext sc = e.getServletContext();
        // get logger instance.
        logger = Logger.getLogger("global");
        // TODO: Should really be injected.
        try {
            FileHandler fh = null;
            String root = sc.getRealPath("/");
            // TODO: Again value should be injected.
            fh = new FileHandler(root+"WEB-INF/log.txt");
            CustomFormatter cf = new CustomFormatter();
        } catch(IOException ioe) {
            System.err.println("Can't load logger" + ioe.getMessage());
        sc.setAttribute("fw.logging.SiteLogger", logger);

here is the web.xml entry for the listener:


here is the code that does the logging in the controller's perform() method:

import fw.logging.SiteLogger;
SiteLogger.getLogger().log(Level.INFO, obj);


Jeff Schnitzer wrote:
Unfortunately I'm pretty sure that's going to be far too general a question.  You need to explain how your logging framework works if anyone's going to be able to help you.  Does it do anything weird with classloaders?


Louis Malenica wrote:

I am trying to log via a standard custom logger from within the
perform() method of a controller that extends ThrowawayBean2. HOwever
nothing is being logged. My logging framework seems ok as it is
logging elsewhere in the app. Anyone come across this before?


Rȧ�:&q�[���y�hv����^y�h��i��py���z�r��!���n}�h�ꮉ�%����ފ{^���y�^r 薈2����쨺��m欉�ã    塧HŞm*az����bq�b�t���]5m�v���!xg��x�� m���zV���ږF�����\�ОI"t
׮6 �@,��8��R===

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

Reply via email to