Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
1365:4c65c5b60a86 | 1366:d0eb2202ffbe |
---|---|
1 package de.intevation.flys.client.server; | |
2 | |
3 import javax.servlet.ServletException; | |
4 import javax.servlet.http.HttpServlet; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 import org.apache.log4j.PropertyConfigurator; | |
8 | |
9 | |
10 public class BaseServlet extends HttpServlet { | |
11 | |
12 private static Logger logger = Logger.getLogger(BaseServlet.class); | |
13 | |
14 | |
15 @Override | |
16 public void init() | |
17 throws ServletException | |
18 { | |
19 System.out.println("BaseServlet.init"); | |
20 | |
21 String log4jProperties = getInitParameter("log4j-properties"); | |
22 | |
23 if (log4jProperties != null && log4jProperties.length() > 0) { | |
24 String file = getServletContext().getRealPath(log4jProperties); | |
25 | |
26 PropertyConfigurator.configure(file); | |
27 | |
28 logger.info("Log4J logging initialized."); | |
29 } | |
30 else { | |
31 System.out.println("Error while setting up Log4J configuration."); | |
32 } | |
33 | |
34 System.out.println("BaseServlet.init finished"); | |
35 } | |
36 } |