001/*
002 * Copyright 2002-2012 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.web.util;
018
019import javax.servlet.ServletContextEvent;
020import javax.servlet.ServletContextListener;
021
022/**
023 * Bootstrap listener for custom log4j initialization in a web environment.
024 * Delegates to {@link Log4jWebConfigurer} (see its javadoc for configuration details).
025 *
026 * <b>WARNING: Assumes an expanded WAR file</b>, both for loading the configuration
027 * file and for writing the log files. If you want to keep your WAR unexpanded or
028 * don't need application-specific log files within the WAR directory, don't use
029 * log4j setup within the application (thus, don't use Log4jConfigListener or
030 * Log4jConfigServlet). Instead, use a global, VM-wide log4j setup (for example,
031 * in JBoss) or JDK 1.4's {@code java.util.logging} (which is global too).
032 *
033 * <p>This listener should be registered before ContextLoaderListener in {@code web.xml}
034 * when using custom log4j initialization.
035 *
036 * @author Juergen Hoeller
037 * @since 13.03.2003
038 * @see Log4jWebConfigurer
039 * @see org.springframework.web.context.ContextLoaderListener
040 * @see WebAppRootListener
041 * @deprecated as of Spring 4.2.1, in favor of Apache Log4j 2
042 * (following Apache's EOL declaration for log4j 1.x)
043 */
044@Deprecated
045public class Log4jConfigListener implements ServletContextListener {
046
047        @Override
048        public void contextInitialized(ServletContextEvent event) {
049                Log4jWebConfigurer.initLogging(event.getServletContext());
050        }
051
052        @Override
053        public void contextDestroyed(ServletContextEvent event) {
054                Log4jWebConfigurer.shutdownLogging(event.getServletContext());
055        }
056
057}