Mercurial > dive4elements > gnv-client
comparison gnv/src/main/java/de/intevation/gnv/servlet/GNVActionServlet.java @ 24:ec56ef8f3e58
Configurable logging integrated in the Web-Application
gnv/trunk@120 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Thu, 24 Sep 2009 08:18:34 +0000 |
parents | fe6a64545552 |
children | 4405f31bbc30 |
comparison
equal
deleted
inserted
replaced
23:b11f941f7eb2 | 24:ec56ef8f3e58 |
---|---|
6 import javax.servlet.ServletConfig; | 6 import javax.servlet.ServletConfig; |
7 import javax.servlet.ServletException; | 7 import javax.servlet.ServletException; |
8 | 8 |
9 import org.apache.log4j.BasicConfigurator; | 9 import org.apache.log4j.BasicConfigurator; |
10 import org.apache.log4j.Logger; | 10 import org.apache.log4j.Logger; |
11 import org.apache.log4j.PropertyConfigurator; | |
11 import org.apache.struts.action.ActionServlet; | 12 import org.apache.struts.action.ActionServlet; |
12 | 13 |
13 import de.intevation.gnv.propertiesreader.PropertiesReaderFactory; | 14 import de.intevation.gnv.propertiesreader.PropertiesReaderFactory; |
14 | 15 |
15 /** | 16 /** |
20 public class GNVActionServlet extends ActionServlet { | 21 public class GNVActionServlet extends ActionServlet { |
21 /** | 22 /** |
22 * the logger, used to log exceptions and additonaly information | 23 * the logger, used to log exceptions and additonaly information |
23 */ | 24 */ |
24 private static Logger log = null; | 25 private static Logger log = null; |
26 | |
27 static { | |
28 //BasicConfigurator.configure(); | |
29 | |
30 } | |
25 | 31 |
26 static { | 32 static String LOGGINIG_CONFIG_FILE_ID = "de.intevation.gnv.servlet.log4j.configuration"; |
27 BasicConfigurator.configure(); | |
28 log = Logger.getLogger(GNVActionServlet.class); | |
29 } | |
30 | 33 |
31 /** | 34 /** |
32 * The UID of this Class | 35 * The UID of this Class |
33 */ | 36 */ |
34 private static final long serialVersionUID = 3597396283436383943L; | 37 private static final long serialVersionUID = 3597396283436383943L; |
36 /** | 39 /** |
37 * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig) | 40 * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig) |
38 */ | 41 */ |
39 public void init(ServletConfig config) throws ServletException { | 42 public void init(ServletConfig config) throws ServletException { |
40 super.init(config); | 43 super.init(config); |
44 try { | |
45 String path = config.getServletContext().getRealPath("/")+config.getInitParameter(LOGGINIG_CONFIG_FILE_ID); | |
46 PropertyConfigurator.configure(path); | |
47 log = Logger.getLogger(GNVActionServlet.class); | |
48 } catch (Exception e) { | |
49 log.error(e,e); | |
50 } | |
41 log.info("PropertiesReader will be configured."); | 51 log.info("PropertiesReader will be configured."); |
42 PropertiesReaderFactory.getInstance().initPropertiesReader(config); | 52 PropertiesReaderFactory.getInstance().initPropertiesReader(config); |
43 } | 53 } |
44 } | 54 } |