1. /*
  2. * Copyright 2002-2004 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springframework.web.util;
  17. import javax.servlet.ServletContextEvent;
  18. import javax.servlet.ServletContextListener;
  19. /**
  20. * Bootstrap listener for custom Log4J initialization in a web environment.
  21. * Simply delegates to Log4jWebConfigurer.
  22. *
  23. * <p>This listener should be registered before ContextLoaderListener
  24. * in web.xml, when using custom Log4J initialization.
  25. *
  26. * <p>For Servlet 2.2 containers and Servlet 2.3 ones that do not
  27. * initalize listeners before servlets, use Log4jConfigServlet.
  28. * See the ContextLoaderServlet javadoc for details.
  29. *
  30. * @author Juergen Hoeller
  31. * @since 13.03.2003
  32. * @see org.springframework.web.util.Log4jWebConfigurer
  33. * @see Log4jConfigServlet
  34. * @see org.springframework.web.context.ContextLoaderListener
  35. * @see org.springframework.web.context.ContextLoaderServlet
  36. * @see WebAppRootListener
  37. */
  38. public class Log4jConfigListener implements ServletContextListener {
  39. public void contextInitialized(ServletContextEvent event) {
  40. Log4jWebConfigurer.initLogging(event.getServletContext());
  41. }
  42. public void contextDestroyed(ServletContextEvent event) {
  43. Log4jWebConfigurer.shutdownLogging(event.getServletContext());
  44. }
  45. }