Re: Cayenne logging

From: Michael Gentry (mgentr..asslight.net)
Date: Thu Jun 11 2009 - 13:46:46 EDT

  • Next message: Joe Baldwin: "Re: Cayenne logging"

    Hi Joe, I think you want an Application Listener. This is a class
    that implements javax.servlet.ServletContextListener which a servlet
    engine (such as Tomcat) is supposed to notify on application startup.
    For example:

    public class ApplicationListener implements ServletContextListener
    {
    ...
    public void contextInitialized(ServletContextEvent sce) {}
    public void contextDestroyed(ServletContextEvent sce) {}
    ...
    }

    You'd put your log4j/etc initialization in contextInitialized().
    You'll also need to add to your web.xml file:

    <listener>
      <listener-class>com.foo.bar.ApplicationListener</listener-class>
    </listener>

    This informs the servlet engine (Tomcat) which listener class to use.
    There is also a listener for session events should you need it
    (implement javax.servlet.http.HttpSessionListener somewhere and add
    another <listener> section in web.xml). The listeners should work in
    all servlet engines (Tomcat, Jetty, etc).

    mrg

    On Thu, Jun 11, 2009 at 12:01 PM, Joe Baldwin<jfbaldwi..arthlink.net> wrote:
    > I remember reading this in your docs.  However, since the scenario is a
    > Tomcat webapp, I am not exactly sure where it is in the code that the app
    > "starts".  I think that this was a topic in your discussion (that I read,
    > possibly for an older version), and it suggested that the
    > cayenne-log.properties should be placed in a hidden directory ".cayenne" in
    > the search path (which, I assume for a WebApp is either WEB-INF/lib or
    > WEB-INF/config/cayenne-files - if you use the web.xml filter).   <= could
    > not get either of these to work btw.
    >



    This archive was generated by hypermail 2.0.0 : Thu Jun 11 2009 - 13:47:26 EDT