Migrated to Log4j2.

This commit is contained in:
Christian P. MOMON 2021-12-28 18:27:23 +01:00
parent 28cdbd5c0c
commit 8f909070a1
25 changed files with 99 additions and 37 deletions

13
log4j.properties Normal file
View file

@ -0,0 +1,13 @@
# Log configuration
# #################
# priority setting: DEBUG < INFO < WARN < ERROR
log4j.rootLogger = INFO, console
log4j.logger.eu.libreservice.www = INFO
log4j.logger.fr.devinsy.xidyn = WARN
#--
log4j.appender.console = org.apache.log4j.ConsoleAppender
log4j.appender.console.layout = org.apache.log4j.PatternLayout
#log4j.appender.console.layout.ConversionPattern = %d{ISO8601} - LibreServiceEuWeb [%-5p] %34.34c.%25M - %m%n
log4j.appender.console.layout.ConversionPattern = %m%n

View file

@ -47,7 +47,6 @@ public class AudioPage extends HttpServlet
@Override @Override
public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException
{ {
logger.debug("Htmlize about page.");
try try
{ {
// Get parameters. // Get parameters.
@ -72,8 +71,6 @@ public class AudioPage extends HttpServlet
{ {
ErrorView.show(request, response, "Error", exception.getMessage(), null); ErrorView.show(request, response, "Error", exception.getMessage(), null);
} }
logger.debug("doGet done.");
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -18,15 +18,13 @@
*/ */
package eu.libreservice.www; package eu.libreservice.www;
import org.apache.log4j.BasicConfigurator; import org.apache.logging.log4j.Level;
import org.apache.log4j.Level; import org.apache.logging.log4j.core.config.Configurator;
import org.apache.log4j.Logger; import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import eu.libreservice.www.LibreServiceEuWebException;
/** /**
* The Class JugaTest. * The Class JugaTest.
* *
@ -66,7 +64,7 @@ public class LibreServiceEuTest
@BeforeClass @BeforeClass
public static void beforeClass() throws LibreServiceEuWebException public static void beforeClass() throws LibreServiceEuWebException
{ {
BasicConfigurator.configure(); Configurator.initialize(new DefaultConfiguration());
Logger.getRootLogger().setLevel(Level.DEBUG); Configurator.setRootLevel(Level.DEBUG);
} }
} }

View file

@ -49,7 +49,7 @@
<Environment name="kiss4web.website.url" value="http://localhost:8080/" type="java.lang.String" override="true"/> <Environment name="kiss4web.website.url" value="http://localhost:8080/" type="java.lang.String" override="true"/>
<!-- Define where is the log4file. --> <!-- Define where is the log4file. -->
<Environment name="kiss4web.log4j.path" value="WEB-INF/log4j.properties" type="java.lang.String" override="true"/> <Environment name="kiss4web.log4j.path" value="WEB-INF/log4j2.properties" type="java.lang.String" override="true"/>
<!-- Define where is the LibreServiceEUWEb configuration file. --> <!-- Define where is the LibreServiceEUWEb configuration file. -->
<Environment name="libreserviceeusweb.configuration.file" value="/home/cpm/Projets/Libre-service.eu/EnvTest/conf/libreserviceeu.conf" type="java.lang.String" override="true"/> <Environment name="libreserviceeusweb.configuration.file" value="/home/cpm/Projets/Libre-service.eu/EnvTest/conf/libreserviceeu.conf" type="java.lang.String" override="true"/>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,26 +0,0 @@
# Log information (priority setting : DEBUG < INFO < WARN < ERROR)
# ################
log4j.rootLogger = INFO, CONSOLE
log4j.logger.fr.devinsy.kiss4web = DEBUG
log4j.logger.fr.devinsy.xidyn = INFO
log4j.logger.fr.devinsy.xidyn.Presenter = INFO
log4j.logger.fr.devinsy.xidyn.FilePresenter = DEBUG
log4j.logger.eu.libreservice.www = DEBUG
#--
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern = %d{ISO8601} - LibreServiceEuWeb [%-5p] %34.34c.%25M %t - %m%n
#--
log4j.appender.LibreServiceEUWeb-Writer = org.apache.log4j.RollingFileAppender
log4j.appender.LibreServiceEUWeb-Writer.File = /services/LibreServiceEuWeb/libreserviceeuweb.log
log4j.appender.LibreServiceEUWeb-Writer.MaxFileSize = 100000KB
log4j.appender.LibreServiceEUWeb-Writer.MaxBackupIndex = 100
log4j.appender.LibreServiceEUWeb-Writer.layout = org.apache.log4j.PatternLayout
log4j.appender.LibreServiceEUWeb-Writer.layout.ConversionPattern = %d{ISO8601} - LibreServiceEuWeb [%-5p] %-50c.%30M - %m%n

View file

@ -0,0 +1,80 @@
# Log information (priority setting : DEBUG < INFO < WARN < ERROR)
# ################
dest = err
name = Log4j2PropertiesConfig
status = TRACE
# Appenders settings.
appenders = console, logfile
appender.console.type = Console
appender.console.name = LogToConsole
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{ISO8601} - LibreServiceEuWeb [%-5p] %34.34c.%25M %t - %m%n
appender.logfile.type = RollingFile
appender.logfile.name = LibreServiceEUWeb
appender.logfile.fileName = /srv/www.libre-service.eu/libreserviceeuweb.log
appender.logfile.filePattern = /srv/www.libre-service.eu/libreserviceeuweb-%i.log.gz
appender.logfile.layout.type = PatternLayout
appender.logfile.layout.pattern = %d{ISO8601} - LibreServiceEuWeb [%-5p] %-50c.%30M - %m%n
appender.logfile.policies.type = Policies
appender.logfile.policies.size.type = SizeBasedTriggeringPolicy
appender.logfile.policies.size.size=10MB
appender.logfile.strategy.type = DefaultRolloverStrategy
appender.logfile.strategy.max = 5
# Logger settings.
rootLogger.level = DEBUG
rootLogger.appenderRefs = a, b
rootLogger.appenderRef.a.ref = LogToConsole
rootLogger.appenderRef.b.ref = LibreServiceEUWeb
logger.kiss4web.name = fr.devinsy.kiss4web
logger.kiss4web.level = DEBUG
logger.xidyn.name = fr.devinsy.xidyn
logger.xidyn.level = INFO
logger.xidyn2.name = fr.devinsy.xidyn.FilePresenter
logger.xidyn2.level = DEBUG
#property.filename = target/rolling/rollingtest.log
#
#filter.threshold.type = ThresholdFilter
#filter.threshold.level = DEBUG
#
#appender.console.type = Console
#appender.console.name = STDOUT
#appender.console.layout.type = PatternLayout
#appender.console.layout.pattern = %d{ISO8601} - LibreServiceEuWeb [%-5p] %34.34c.%25M %t - %m%n
#appender.console.filter.threshold.type = ThresholdFilter
#appender.console.filter.threshold.level = DEBUG
#
##--
#appender.logfile.type = RollingFile
#appender.logfile.name = LibreServiceEUWeb
#appender.rolling.fileName = /services/LibreServiceEuWeb/libreserviceeuweb.log
#appender.rolling.layout.type = PatternLayout
#appender.rolling.layout.pattern = %d{ISO8601} - LibreServiceEuWeb [%-5p] %-50c.%30M - %m%n
#appender.rolling.policies.type = Policies
#appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
#appender.rolling.policies.time.interval = 2
#appender.rolling.policies.time.modulate = true
#appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
#appender.rolling.policies.size.size=100MB
#appender.rolling.strategy.type = DefaultRolloverStrategy
#appender.rolling.strategy.max = 5
#
#logger.console.name = fr.devinsy.kiss4web
#logger.console.level = DEBUG
#logger.console.additivity = false
#logger.console.appenderRef.console.ref = Console
#
#logger.console.name = eu.libreservice.www
#logger.console.level = DEBUG
#
#rootLogger.level = DEBUG
#rootLogger.appenderRef.stdout.ref = STDOUT