Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/server/BaseServletContextListener.java @ 9724:654aaa0d7576 3.2.x
Rely on log4j's default initialization procedure
This should make upgrading to Log4j 2.x easier.
In passing, use latest Log4j 1.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 25 Feb 2022 17:13:49 +0100 |
parents | 5e38e2924c07 |
children | 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
9723:de83690667fe | 9724:654aaa0d7576 |
---|---|
23 * ServletContextListenter to initalize the Features globally for | 23 * ServletContextListenter to initalize the Features globally for |
24 * all Servlets | 24 * all Servlets |
25 */ | 25 */ |
26 public class BaseServletContextListener implements ServletContextListener { | 26 public class BaseServletContextListener implements ServletContextListener { |
27 | 27 |
28 public static final String LOG4J_PROPERTIES = "FLYS_CLIENT_LOG4J_PROPERIES"; | |
29 | |
30 public static final Logger log = Logger.getLogger( | 28 public static final Logger log = Logger.getLogger( |
31 BaseServletContextListener.class); | 29 BaseServletContextListener.class); |
32 | 30 |
33 @Override | 31 @Override |
34 public void contextInitialized(ServletContextEvent sce) { | 32 public void contextInitialized(ServletContextEvent sce) { |
35 ServletContext sc = sce.getServletContext(); | 33 ServletContext sc = sce.getServletContext(); |
36 | |
37 this.initLogging(sc); | |
38 | 34 |
39 String filename = sc.getInitParameter("features-file"); | 35 String filename = sc.getInitParameter("features-file"); |
40 | 36 |
41 log.debug("Initializing ServletContext"); | 37 log.debug("Initializing ServletContext"); |
42 try { | 38 try { |
50 | 46 |
51 @Override | 47 @Override |
52 public void contextDestroyed(ServletContextEvent sce) { | 48 public void contextDestroyed(ServletContextEvent sce) { |
53 //DO NOTHING | 49 //DO NOTHING |
54 } | 50 } |
55 | |
56 | |
57 private void initLogging(ServletContext sc) { | |
58 String log4jProperties = System.getenv(LOG4J_PROPERTIES); | |
59 | |
60 if (log4jProperties == null || log4jProperties.length() == 0) { | |
61 String file = sc.getInitParameter("log4j-properties"); | |
62 | |
63 if (file != null && file.length() > 0) { | |
64 log4jProperties = sc.getRealPath(file); | |
65 } | |
66 } | |
67 System.out.println(log4jProperties); | |
68 | |
69 LoggingConfigurator.init(log4jProperties); | |
70 } | |
71 } | 51 } |