cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject Re: Cayenne logging
Date Thu, 11 Jun 2009 17:46:46 GMT
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<jfbaldwin@earthlink.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.
>

Mime
View raw message