# HG changeset patch # User Tim Englich # Date 1253780314 0 # Node ID ec56ef8f3e582799dcf17aabf177ab7521c645ee # Parent b11f941f7eb2e9841e2aa395b435a5e06bccdd50 Configurable logging integrated in the Web-Application gnv/trunk@120 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r b11f941f7eb2 -r ec56ef8f3e58 gnv/Changelog --- a/gnv/Changelog Wed Sep 23 15:29:26 2009 +0000 +++ b/gnv/Changelog Thu Sep 24 08:18:34 2009 +0000 @@ -1,3 +1,13 @@ +2009-09-24 Tim Englich + + * src/main/webapp/WEB-INF/config/log4j.properties Added: + Standard Log4J-properties-File which will log all Informations to the Console. + * src/main/webapp/WEB-INF/web.xml Edited: + Added init-Parameter to tell the Application where the Log4J-propertiesfile ist located. + * src/main/java/de/intevation/gnv/servlet/GNVActionServlet.java (init) Edited: + Reading Logging-Properties from Propertiesfile. Path maust beconfigured in the web.xml File + + 2009-09-23 Tim Englich * src/main/webapp/WEB-INF/web.xml Edited: diff -r b11f941f7eb2 -r ec56ef8f3e58 gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java --- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Wed Sep 23 15:29:26 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Thu Sep 24 08:18:34 2009 +0000 @@ -50,6 +50,7 @@ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + log.debug("NextArtifactStepAction.execute"); SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); ArtifactDescription ad = (ArtifactDescription)sm.getCurrentArtifact(); Collection inputParameter = ad.getInputParameter(); diff -r b11f941f7eb2 -r ec56ef8f3e58 gnv/src/main/java/de/intevation/gnv/servlet/GNVActionServlet.java --- a/gnv/src/main/java/de/intevation/gnv/servlet/GNVActionServlet.java Wed Sep 23 15:29:26 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/servlet/GNVActionServlet.java Thu Sep 24 08:18:34 2009 +0000 @@ -8,6 +8,7 @@ import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; import org.apache.struts.action.ActionServlet; import de.intevation.gnv.propertiesreader.PropertiesReaderFactory; @@ -22,12 +23,14 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = null; - + static { - BasicConfigurator.configure(); - log = Logger.getLogger(GNVActionServlet.class); + //BasicConfigurator.configure(); + } + static String LOGGINIG_CONFIG_FILE_ID = "de.intevation.gnv.servlet.log4j.configuration"; + /** * The UID of this Class */ @@ -38,6 +41,13 @@ */ public void init(ServletConfig config) throws ServletException { super.init(config); + try { + String path = config.getServletContext().getRealPath("/")+config.getInitParameter(LOGGINIG_CONFIG_FILE_ID); + PropertyConfigurator.configure(path); + log = Logger.getLogger(GNVActionServlet.class); + } catch (Exception e) { + log.error(e,e); + } log.info("PropertiesReader will be configured."); PropertiesReaderFactory.getInstance().initPropertiesReader(config); } diff -r b11f941f7eb2 -r ec56ef8f3e58 gnv/src/main/webapp/WEB-INF/config/log4j.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/webapp/WEB-INF/config/log4j.properties Thu Sep 24 08:18:34 2009 +0000 @@ -0,0 +1,13 @@ +# Set root logger level to DEBUG and its only appender to A1. +log4j.rootLogger=DEBUG, A1 + +# A1 is set to be a ConsoleAppender. +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n + +# Abschalten des geschwätzigen Loggings in dre Klasse JspServlet +log4j.category.org.apache.jasper.servlet.JspServlet=WARN +log4j.category.org.apache.catalina.core.ContainerBase=WARN \ No newline at end of file diff -r b11f941f7eb2 -r ec56ef8f3e58 gnv/src/main/webapp/WEB-INF/web.xml --- a/gnv/src/main/webapp/WEB-INF/web.xml Wed Sep 23 15:29:26 2009 +0000 +++ b/gnv/src/main/webapp/WEB-INF/web.xml Thu Sep 24 08:18:34 2009 +0000 @@ -11,6 +11,10 @@ config /WEB-INF/config/struts-config.xml + + de.intevation.gnv.servlet.log4j.configuration + WEB-INF/config/log4j.properties + de.intevation.gnv.artifactdatabase.client.ArtifactDatabase.count