changeset 1372:2ba44c1b2bab

Added a environment variable that might be used to use an alternative log4j properties file. flys-client/trunk@3081 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 26 Oct 2011 09:06:09 +0000
parents 2582c06c3774
children d6fd4391d1d5
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/BaseServlet.java
diffstat 2 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Oct 26 08:28:02 2011 +0000
+++ b/flys-client/ChangeLog	Wed Oct 26 09:06:09 2011 +0000
@@ -1,3 +1,10 @@
+2011-10-26  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/server/BaseServlet.java: Added a
+	  an environment variable FLYS_CLIENT_LOG4J_PROPERIES that might be used
+	  to use an alternative log4j.properties instead of the default one which
+	  comes with the SVN. This variable needs to point to a properties file.
+
 2011-10-26  Ingo Weinzierl <ingo@intevation.de>
 
 	* .: Modified svn:ignore property to ignore log4j.properties.
--- a/flys-client/src/main/java/de/intevation/flys/client/server/BaseServlet.java	Wed Oct 26 08:28:02 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/BaseServlet.java	Wed Oct 26 09:06:09 2011 +0000
@@ -12,6 +12,9 @@
     private static Logger logger = Logger.getLogger(BaseServlet.class);
 
 
+    public static final String LOG4J_PROPERTIES = "FLYS_CLIENT_LOG4J_PROPERIES";
+
+
     @Override
     public void init()
     throws ServletException
@@ -24,13 +27,18 @@
 
 
     protected void initLogging() {
-        String log4jProperties = getInitParameter("log4j-properties");
+        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) {
-            String file = getServletContext().getRealPath(log4jProperties);
-
-            PropertyConfigurator.configure(file);
-
+            PropertyConfigurator.configure(log4jProperties);
             logger.info("Log4J logging initialized.");
         }
         else {

http://dive4elements.wald.intevation.org