Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/server/BaseServlet.java @ 3807:d73c43798a99 pre2.6-2011-11-04
merged flys-backend/pre2.6-2011-11-04
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:51 +0200 |
parents | 2ba44c1b2bab |
children | 42d6cf6e10b7 |
line wrap: on
line source
package de.intevation.flys.client.server; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; public class BaseServlet extends HttpServlet { private static Logger logger = Logger.getLogger(BaseServlet.class); public static final String LOG4J_PROPERTIES = "FLYS_CLIENT_LOG4J_PROPERIES"; @Override public void init() throws ServletException { System.out.println("BaseServlet.init"); initLogging(); initConfigParameters(); } protected void initLogging() { String log4jProperties = System.getenv(LOG4J_PROPERTIES); if (log4jProperties == null || log4jProperties.length() == 0) { String file = getInitParameter("log4j-properties"); if (file != null && file.length() > 0) { log4jProperties = getServletContext().getRealPath(file); } } if (log4jProperties != null && log4jProperties.length() > 0) { PropertyConfigurator.configure(log4jProperties); logger.info("Log4J logging initialized."); } else { System.out.println("Error while setting up Log4J configuration."); } System.out.println("BaseServlet.init finished"); } protected void initConfigParameters() { String url = getInitParameter("server-url"); logger.debug("Found server url: " + url); getServletContext().setAttribute("server-url", url); } }