Author: echatellier Date: 2014-08-12 17:59:54 +0200 (Tue, 12 Aug 2014) New Revision: 528 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/528 Log: Move to log4j2 to allow using sys var in property files Added: trunk/faxtomail-service/src/test/resources/log4j2.xml trunk/faxtomail-ui-swing/src/main/resources/log4j2.xml trunk/faxtomail-ui-web/src/main/resources/log4j2.xml Removed: trunk/faxtomail-service/src/test/resources/log4j.properties trunk/faxtomail-ui-swing/src/main/resources/log4j.properties trunk/faxtomail-ui-web/src/main/resources/log4j.properties Modified: trunk/faxtomail-persistence/pom.xml trunk/faxtomail-service/pom.xml trunk/faxtomail-ui-swing/pom.xml trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/RunFaxToMail.java trunk/faxtomail-ui-web/pom.xml trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/FaxToMailApplicationContext.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailApplicationListener.java trunk/pom.xml Modified: trunk/faxtomail-persistence/pom.xml =================================================================== --- trunk/faxtomail-persistence/pom.xml 2014-08-12 15:01:33 UTC (rev 527) +++ trunk/faxtomail-persistence/pom.xml 2014-08-12 15:59:54 UTC (rev 528) @@ -112,28 +112,6 @@ <groupId>org.swinglabs.swingx</groupId> <artifactId>swingx-common</artifactId> </dependency> - - <!-- Logging --> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-jcl</artifactId> - <scope>runtime</scope> - </dependency> - - <!-- Test --> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <scope>test</scope> - </dependency> - </dependencies> <build> Modified: trunk/faxtomail-service/pom.xml =================================================================== --- trunk/faxtomail-service/pom.xml 2014-08-12 15:01:33 UTC (rev 527) +++ trunk/faxtomail-service/pom.xml 2014-08-12 15:59:54 UTC (rev 528) @@ -67,6 +67,11 @@ <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </dependency> + + <dependency> + <groupId>com.mchange</groupId> + <artifactId>c3p0</artifactId> + </dependency> <dependency> <groupId>org.nuiton</groupId> @@ -145,14 +150,20 @@ <!-- Logging --> <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-jcl</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jcl</artifactId> + <scope>test</scope> + </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> <scope>test</scope> </dependency> Deleted: trunk/faxtomail-service/src/test/resources/log4j.properties =================================================================== --- trunk/faxtomail-service/src/test/resources/log4j.properties 2014-08-12 15:01:33 UTC (rev 527) +++ trunk/faxtomail-service/src/test/resources/log4j.properties 2014-08-12 15:59:54 UTC (rev 528) @@ -1,29 +0,0 @@ -### -# #%L -# FaxToMail :: UI -# %% -# Copyright (C) 2014 Franciaflex -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -log4j.rootCategory=ERROR, console - -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} %5p (%F:%L) %M %m%n - -# global level -log4j.logger.com.franciaflex.faxtomail.services.service=INFO Added: trunk/faxtomail-service/src/test/resources/log4j2.xml =================================================================== --- trunk/faxtomail-service/src/test/resources/log4j2.xml (rev 0) +++ trunk/faxtomail-service/src/test/resources/log4j2.xml 2014-08-12 15:59:54 UTC (rev 528) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{yyyy/MM/dd HH:mm:ss} %5p (%c:%L) - %m%n" /> + </Console> + </Appenders> + + <Loggers> + <Logger name="com.franciaflex.faxtomail.services.service" level="info"/> + + <Root level="error"> + <AppenderRef ref="Console" /> + </Root> + </Loggers> +</Configuration> \ No newline at end of file Property changes on: trunk/faxtomail-service/src/test/resources/log4j2.xml ___________________________________________________________________ Added: svn:eol-style + native Added: svn:mime-type + text/xml Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/faxtomail-ui-swing/pom.xml =================================================================== --- trunk/faxtomail-ui-swing/pom.xml 2014-08-12 15:01:33 UTC (rev 527) +++ trunk/faxtomail-ui-swing/pom.xml 2014-08-12 15:59:54 UTC (rev 528) @@ -188,16 +188,21 @@ </dependency> <!-- Logging --> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-jcl</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jcl</artifactId> <scope>runtime</scope> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> <scope>runtime</scope> </dependency> Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/RunFaxToMail.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/RunFaxToMail.java 2014-08-12 15:01:33 UTC (rev 527) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/RunFaxToMail.java 2014-08-12 15:59:54 UTC (rev 528) @@ -26,12 +26,15 @@ import com.franciaflex.faxtomail.ui.swing.content.MainUI; import com.franciaflex.faxtomail.ui.swing.content.MainUIHandler; import com.franciaflex.faxtomail.ui.swing.util.FaxToMailExceptionHandler; + import jaxx.runtime.SwingUtil; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.swing.*; import javax.swing.plaf.BorderUIResource; + import java.awt.*; import java.io.IOException; import java.util.Arrays; @@ -55,6 +58,9 @@ log.info("Starting FaxToMail with arguments: " + Arrays.toString(args)); } + // TODO as of 20140812, hibernate fails to detect log4j 2.0, force slf4j + System.setProperty("org.jboss.logging.provider", "slf4j"); + // Create configuration FaxToMailConfiguration config = new FaxToMailConfiguration("faxToMail.properties", args); Deleted: trunk/faxtomail-ui-swing/src/main/resources/log4j.properties =================================================================== --- trunk/faxtomail-ui-swing/src/main/resources/log4j.properties 2014-08-12 15:01:33 UTC (rev 527) +++ trunk/faxtomail-ui-swing/src/main/resources/log4j.properties 2014-08-12 15:59:54 UTC (rev 528) @@ -1,41 +0,0 @@ -### -# #%L -# FaxToMail :: UI -# %% -# Copyright (C) 2014 Franciaflex -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -# Global logging configuration -log4j.rootLogger=ERROR, stdout - -# Console output -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %5p (%c:%L) - %m%n - -# faxtomail levels -log4j.logger.com.franciaflex.faxtomail=INFO -log4j.logger.com.franciaflex.faxtomail.services=DEBUG - -#log4j.appender.file=org.apache.log4j.RollingFileAppender -#log4j.appender.file.file=${faxtomail.log.file} -#log4j.appender.file.MaxFileSize=10MB -#log4j.appender.file.MaxBackupIndex=4 - -#log4j.appender.file.layout=org.apache.log4j.PatternLayout -#log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p [%20t] %c - %m%n -#log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p %c - %m%n Added: trunk/faxtomail-ui-swing/src/main/resources/log4j2.xml =================================================================== --- trunk/faxtomail-ui-swing/src/main/resources/log4j2.xml (rev 0) +++ trunk/faxtomail-ui-swing/src/main/resources/log4j2.xml 2014-08-12 15:59:54 UTC (rev 528) @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{yyyy/MM/dd HH:mm:ss} %5p (%c:%L) - %m%n" /> + </Console> + + <RollingFile name="File" fileName="${sys:user.home}/.faxtomail/faxtomail.log" + filePattern="${sys:user.home}/.faxtomail/faxtomail-%d{yyyyMMdd}-%i.log"> + <PatternLayout> + <pattern>%d{yyyy/MM/dd HH:mm:ss} %5p (%c:%L) - %m%n</pattern> + </PatternLayout> + <Policies> + <TimeBasedTriggeringPolicy /> + <SizeBasedTriggeringPolicy size="10 MB"/> + </Policies> + <DefaultRolloverStrategy max="5"/> + </RollingFile> + </Appenders> + + <Loggers> + <Logger name="com.franciaflex.faxtomail" level="info"/> + <!-- <Logger name="com.franciaflex.faxtomail.services" level="debug"/> --> + + <Root level="warn"> + <AppenderRef ref="Console" /> + <AppenderRef ref="File" /> + </Root> + </Loggers> +</Configuration> \ No newline at end of file Property changes on: trunk/faxtomail-ui-swing/src/main/resources/log4j2.xml ___________________________________________________________________ Added: svn:eol-style + native Added: svn:mime-type + text/xml Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/faxtomail-ui-web/pom.xml =================================================================== --- trunk/faxtomail-ui-web/pom.xml 2014-08-12 15:01:33 UTC (rev 527) +++ trunk/faxtomail-ui-web/pom.xml 2014-08-12 15:59:54 UTC (rev 528) @@ -47,9 +47,6 @@ <defaultWebContextPath>faxtomail</defaultWebContextPath> <defaultSiteUrl>http://localhost:8080/${defaultWebContextPath}</defaultSiteUrl> - <!-- XXX voir le profil le profil removeSlf4jJclFromClassPath --> - <slf4jJclScope>runtime</slf4jJclScope> - <devMode>true</devMode> <jsMinimize>false</jsMinimize> <jsCachePeriod>1</jsCachePeriod> @@ -162,17 +159,22 @@ <artifactId>gson</artifactId> </dependency> - <!-- FIXME bleny 2013/12/18 need to be removed to do a tomcat:run since shiro was added --> <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-jcl</artifactId> - <scope>${slf4jJclScope}</scope> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <scope>compile</scope> </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jcl</artifactId> + <scope>runtime</scope> + </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <scope>compile</scope> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <scope>runtime</scope> </dependency> <dependency> @@ -386,14 +388,7 @@ </plugins> </build> - <!-- XXX le profil le profil removeSlf4jJclFromClasspath permet d'exclure cette dépendance du classpath, indispensable pour que tomcat7:run fonctione --> <profiles> - <profile> - <id>removeSlf4jJclFromClasspath</id> - <properties> - <slf4jJclScope>provided</slf4jJclScope> - </properties> - </profile> <profile> <id>disable-devMode-release-profile</id> Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/FaxToMailApplicationContext.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/FaxToMailApplicationContext.java 2014-08-12 15:01:33 UTC (rev 527) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/FaxToMailApplicationContext.java 2014-08-12 15:59:54 UTC (rev 528) @@ -24,7 +24,6 @@ * #L% */ -import java.io.File; import java.util.HashMap; import java.util.Map; @@ -32,8 +31,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.LogManager; -import org.apache.log4j.PropertyConfigurator; import org.nuiton.topia.flyway.TopiaFlywayService; import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaApplicationContext; @@ -103,7 +100,7 @@ // create application topiaApplicationContext = new FaxToMailTopiaApplicationContext(properties); - if (getApplicationConfig().isLogConfigurationProvided()) { + /*if (getApplicationConfig().isLogConfigurationProvided()) { File log4jConfigurationFile = getApplicationConfig().getLogConfigurationFile(); @@ -131,7 +128,7 @@ } else { log.info("will use default logging configuration"); - } + }*/ // I18nInitializer initializer = new DefaultI18nInitializer("faxtomail"); Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailApplicationListener.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailApplicationListener.java 2014-08-12 15:01:33 UTC (rev 527) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailApplicationListener.java 2014-08-12 15:59:54 UTC (rev 528) @@ -61,6 +61,9 @@ log.info("init FaxToMail web ui"); } + // TODO as of 20140812, hibernate fails to detect log4j 2.0, force slf4j + System.setProperty("org.jboss.logging.provider", "slf4j"); + log.debug("scheduler launched"); ServletContext sc = sce.getServletContext(); Deleted: trunk/faxtomail-ui-web/src/main/resources/log4j.properties =================================================================== --- trunk/faxtomail-ui-web/src/main/resources/log4j.properties 2014-08-12 15:01:33 UTC (rev 527) +++ trunk/faxtomail-ui-web/src/main/resources/log4j.properties 2014-08-12 15:59:54 UTC (rev 528) @@ -1,46 +0,0 @@ -### -# #%L -# FaxToMail :: Web -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2014 Franciaflex, Code Lutin -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -log4j.rootCategory=WARN, console - -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} %5p (%F:%L) %M %m%n - -# global level -log4j.logger.com.franciaflex.faxtomail=INFO - -### persistence level -# log4j.logger.org.nuiton.topia=TRACE -# log4j.logger.com.franciaflex.faxtomail.persistence=TRACE - -### services level -# log4j.logger.com.franciaflex.faxtomail.services=TRACE - -### web level -#log4j.logger.com.franciaflex.faxtomail.web.FaxToMailInterceptor=WARN - -# annoying errors -log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=FATAL -log4j.logger.com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler=FATAL -log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack=ERROR Added: trunk/faxtomail-ui-web/src/main/resources/log4j2.xml =================================================================== --- trunk/faxtomail-ui-web/src/main/resources/log4j2.xml (rev 0) +++ trunk/faxtomail-ui-web/src/main/resources/log4j2.xml 2014-08-12 15:59:54 UTC (rev 528) @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{yyyy/MM/dd HH:mm:ss} %5p (%c:%L) - %m%n" /> + </Console> + + <!-- RollingFile name="File" fileName="${sys:user.home}/.faxtomail/faxtomail.log" + filePattern="${sys:user.home}/.faxtomail/faxtomail-%d{yyyyMMdd}-%i.log"> + <PatternLayout> + <pattern>%d %5p (%c:%L) - %m%n</pattern> + </PatternLayout> + <Policies> + <TimeBasedTriggeringPolicy /> + <SizeBasedTriggeringPolicy size="10 MB"/> + </Policies> + <DefaultRolloverStrategy max="5"/> + </RollingFile--> + </Appenders> + + <Loggers> + <Logger name="com.franciaflex.faxtomail" level="info"/> + + <!-- annoying errors --> + <Logger name="com.opensymphony.xwork2.interceptor.ParametersInterceptor" level="FATAL"/> + <Logger name="com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler" level="FATAL"/> + <Logger name="com.opensymphony.xwork2.ognl.OgnlValueStack" level="ERROR"/> + + <Root level="warn"> + <AppenderRef ref="Console" /> + <!-- AppenderRef ref="File" /--> + </Root> + </Loggers> +</Configuration> \ No newline at end of file Property changes on: trunk/faxtomail-ui-web/src/main/resources/log4j2.xml ___________________________________________________________________ Added: svn:eol-style + native Added: svn:mime-type + text/xml Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2014-08-12 15:01:33 UTC (rev 527) +++ trunk/pom.xml 2014-08-12 15:59:54 UTC (rev 528) @@ -118,6 +118,7 @@ <jqueryPluginVersion>3.7.1</jqueryPluginVersion> <bootstrapPluginVersion>2.0.0</bootstrapPluginVersion> <slf4jVersion>1.7.7</slf4jVersion> + <log4jVersion>2.0.1</log4jVersion> <postgresqlDriverVersion>9.3-1102-jdbc41</postgresqlDriverVersion> <commonsEmailVersion>1.3.3</commonsEmailVersion> @@ -226,7 +227,20 @@ <artifactId>hibernate-c3p0</artifactId> <version>${hibernateVersion}</version> <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>c3p0</groupId> + <artifactId>c3p0</artifactId> + </exclusion> + </exclusions> </dependency> + + <dependency> + <groupId>com.mchange</groupId> + <artifactId>c3p0</artifactId> + <version>0.9.5-pre8</version> + <scope>runtime</scope> + </dependency> <dependency> <groupId>org.nuiton</groupId> @@ -340,15 +354,31 @@ </dependency> <!-- Logging --> + <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>${slf4jVersion}</version> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>${log4jVersion}</version> + <scope>compile</scope> </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jcl</artifactId> + <version>${log4jVersion}</version> + <scope>runtime</scope> + </dependency> <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <version>${log4jVersion}</version> + <scope>runtime</scope> + </dependency> + + <dependency> <groupId>org.slf4j</groupId> - <artifactId>slf4j-jcl</artifactId> + <artifactId>slf4j-api</artifactId> <version>${slf4jVersion}</version> </dependency>