changeset 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 4c65c5b60a86
children ab8eb2f544f2
files flys-client/ChangeLog flys-client/pom.xml flys-client/src/main/java/de/intevation/flys/client/server/BaseServlet.java flys-client/src/main/webapp/WEB-INF/log4j.properties flys-client/src/main/webapp/WEB-INF/web.xml
diffstat 5 files changed, 84 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Oct 25 10:29:37 2011 +0000
+++ b/flys-client/ChangeLog	Tue Oct 25 11:07:14 2011 +0000
@@ -1,3 +1,16 @@
+2011-10-25  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/server/BaseServlet.java: New.
+	  This HttpServlet is used to setup some config stuff like log4j
+	  configuration.
+
+	* src/main/webapp/WEB-INF/log4j.properties: A Log4J configuration file.
+
+	* src/main/webapp/WEB-INF/web.xml: Registered the BaseServlet which is
+	  loaded initially to setup config stuff.
+
+	* pom.xml: Added Apache Log4J dependency.
+
 2011-10-25  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/services/MapOutputServiceAsync.java,
--- a/flys-client/pom.xml	Tue Oct 25 10:29:37 2011 +0000
+++ b/flys-client/pom.xml	Tue Oct 25 11:07:14 2011 +0000
@@ -74,6 +74,11 @@
       <artifactId>gwt-openlayers-client</artifactId>
       <version>0.6</version>
     </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.14</version>
+    </dependency>
   </dependencies>
   
   <build>
--- /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");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/webapp/WEB-INF/log4j.properties	Tue Oct 25 11:07:14 2011 +0000
@@ -0,0 +1,18 @@
+log4j.rootLogger=DEBUG, FLYS
+
+########## INTERNAL PACKAGES
+log4j.category.de.intevation.flys.client.server=DEBUG
+
+
+########## EXTERNAL PACKAGES
+log4j.category.org.apache.http=ERROR
+log4j.category.de.intevation.artifacts.httpclient=WARN
+
+########## APPENDER SETTINGS
+log4j.appender.FLYS.layout=org.apache.log4j.PatternLayout
+log4j.appender.FLYS.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+
+log4j.appender.FLYS=org.apache.log4j.RollingFileAppender
+log4j.appender.FLYS.File=/tmp/flys-client.log
+log4j.appender.FLYS.MaxFileSize=5000KB
+log4j.appender.FLYS.MaxBackupIndex=3
--- a/flys-client/src/main/webapp/WEB-INF/web.xml	Tue Oct 25 10:29:37 2011 +0000
+++ b/flys-client/src/main/webapp/WEB-INF/web.xml	Tue Oct 25 11:07:14 2011 +0000
@@ -7,6 +7,18 @@
   
   <!-- Servlets -->
   <servlet>
+    <servlet-name>BaseServlet</servlet-name>
+    <servlet-class>de.intevation.flys.client.server.BaseServlet</servlet-class>
+
+    <init-param>
+        <param-name>log4j-properties</param-name>
+        <param-value>/WEB-INF/log4j.properties</param-value>
+    </init-param>
+
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+
+  <servlet>
     <servlet-name>user</servlet-name>
     <servlet-class>de.intevation.flys.client.server.UserServiceImpl</servlet-class>
   </servlet>

http://dive4elements.wald.intevation.org