ingo@1366: package de.intevation.flys.client.server; ingo@1366: ingo@1366: import javax.servlet.ServletException; ingo@1366: import javax.servlet.http.HttpServlet; ingo@1366: ingo@1366: import org.apache.log4j.Logger; ingo@1366: import org.apache.log4j.PropertyConfigurator; ingo@1366: ingo@1366: ingo@1366: public class BaseServlet extends HttpServlet { ingo@1366: ingo@1366: private static Logger logger = Logger.getLogger(BaseServlet.class); ingo@1366: ingo@1366: ingo@1372: public static final String LOG4J_PROPERTIES = "FLYS_CLIENT_LOG4J_PROPERIES"; ingo@1372: ingo@1372: ingo@1366: @Override ingo@1366: public void init() ingo@1366: throws ServletException ingo@1366: { ingo@1366: System.out.println("BaseServlet.init"); ingo@1366: ingo@1368: initLogging(); ingo@1368: initConfigParameters(); ingo@1368: } ingo@1368: ingo@1368: ingo@1368: protected void initLogging() { ingo@1372: String log4jProperties = System.getenv(LOG4J_PROPERTIES); ingo@1372: ingo@1372: if (log4jProperties == null || log4jProperties.length() == 0) { ingo@1372: String file = getInitParameter("log4j-properties"); ingo@1372: ingo@1372: if (file != null && file.length() > 0) { ingo@1372: log4jProperties = getServletContext().getRealPath(file); ingo@1372: } ingo@1372: } ingo@1366: ingo@1366: if (log4jProperties != null && log4jProperties.length() > 0) { ingo@1372: PropertyConfigurator.configure(log4jProperties); ingo@1366: logger.info("Log4J logging initialized."); ingo@1366: } ingo@1366: else { ingo@1366: System.out.println("Error while setting up Log4J configuration."); ingo@1366: } ingo@1366: ingo@1366: System.out.println("BaseServlet.init finished"); ingo@1366: } ingo@1368: ingo@1368: ingo@1368: protected void initConfigParameters() { ingo@1368: String url = getInitParameter("server-url"); ingo@1368: logger.debug("Found server url: " + url); ingo@1368: ingo@1368: getServletContext().setAttribute("server-url", url); ingo@1368: } ingo@1366: }