comparison flys-client/src/main/java/de/intevation/flys/client/server/BaseServlet.java @ 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 ec0c81f2c7a4
children 42d6cf6e10b7
comparison
equal deleted inserted replaced
1371:2582c06c3774 1372:2ba44c1b2bab
10 public class BaseServlet extends HttpServlet { 10 public class BaseServlet extends HttpServlet {
11 11
12 private static Logger logger = Logger.getLogger(BaseServlet.class); 12 private static Logger logger = Logger.getLogger(BaseServlet.class);
13 13
14 14
15 public static final String LOG4J_PROPERTIES = "FLYS_CLIENT_LOG4J_PROPERIES";
16
17
15 @Override 18 @Override
16 public void init() 19 public void init()
17 throws ServletException 20 throws ServletException
18 { 21 {
19 System.out.println("BaseServlet.init"); 22 System.out.println("BaseServlet.init");
22 initConfigParameters(); 25 initConfigParameters();
23 } 26 }
24 27
25 28
26 protected void initLogging() { 29 protected void initLogging() {
27 String log4jProperties = getInitParameter("log4j-properties"); 30 String log4jProperties = System.getenv(LOG4J_PROPERTIES);
31
32 if (log4jProperties == null || log4jProperties.length() == 0) {
33 String file = getInitParameter("log4j-properties");
34
35 if (file != null && file.length() > 0) {
36 log4jProperties = getServletContext().getRealPath(file);
37 }
38 }
28 39
29 if (log4jProperties != null && log4jProperties.length() > 0) { 40 if (log4jProperties != null && log4jProperties.length() > 0) {
30 String file = getServletContext().getRealPath(log4jProperties); 41 PropertyConfigurator.configure(log4jProperties);
31
32 PropertyConfigurator.configure(file);
33
34 logger.info("Log4J logging initialized."); 42 logger.info("Log4J logging initialized.");
35 } 43 }
36 else { 44 else {
37 System.out.println("Error while setting up Log4J configuration."); 45 System.out.println("Error while setting up Log4J configuration.");
38 } 46 }

http://dive4elements.wald.intevation.org