diff flys-client/src/main/java/de/intevation/flys/client/server/BaseServlet.java @ 1366:d0eb2202ffbe

Added a BaseServlet that is used to setup config things like log4j. flys-client/trunk@3067 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 25 Oct 2011 11:07:14 +0000
parents
children ec0c81f2c7a4
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/BaseServlet.java	Tue Oct 25 11:07:14 2011 +0000
@@ -0,0 +1,36 @@
+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);
+
+
+    @Override
+    public void init()
+    throws ServletException
+    {
+        System.out.println("BaseServlet.init");
+
+        String log4jProperties = getInitParameter("log4j-properties");
+
+        if (log4jProperties != null && log4jProperties.length() > 0) {
+            String file = getServletContext().getRealPath(log4jProperties);
+
+            PropertyConfigurator.configure(file);
+
+            logger.info("Log4J logging initialized.");
+        }
+        else {
+            System.out.println("Error while setting up Log4J configuration.");
+        }
+
+        System.out.println("BaseServlet.init finished");
+    }
+}

http://dive4elements.wald.intevation.org