Migrated to Log4j2.

This commit is contained in:
Christian P. MOMON 2021-12-29 01:00:20 +01:00
parent d5c67afb64
commit 62815f6d1e
22 changed files with 77 additions and 60 deletions

View file

@ -11,11 +11,8 @@
<classpathentry kind="lib" path="lib/commons-codec-1.8.jar" sourcepath="lib/commons-codec-1.8-sources.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="lib/mysql-jdbc-5.0.8.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-1.2.17.jar" sourcepath="lib/Logs/log4j-1.2.17-source.zip"/>
<classpathentry kind="lib" path="lib/UnitTesting/hamcrest-core-1.3.jar" sourcepath="lib/UnitTesting/hamcrest-core-1.3-sources.jar"/>
<classpathentry kind="lib" path="lib/hsqldb-2.3.0.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.25.jar" sourcepath="lib/Logs/slf4j-api-1.7.25-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-log4j12-1.7.25.jar" sourcepath="lib/Logs/slf4j-log4j12-1.7.25-sources.jar"/>
<classpathentry kind="lib" path="lib/UnitTesting/junit-4.12.jar" sourcepath="lib/UnitTesting/junit-4.12-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-cli-1.4.jar" sourcepath="lib/commons-cli-1.4-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.7.jar" sourcepath="lib/commons-io-2.7-sources.jar"/>
@ -27,5 +24,9 @@
<classpathentry kind="lib" path="lib/jOpenDocument-1.3.jar" sourcepath="lib/jOpenDocument-src-1.3.zip"/>
<classpathentry kind="lib" path="lib/threeten-extra-1.5.0.jar" sourcepath="lib/threeten-extra-1.5.0-sources.jar"/>
<classpathentry kind="lib" path="lib/devinsy-strings-0.11.4.jar" sourcepath="lib/devinsy-strings-0.11.4-sources.zip"/>
<classpathentry kind="lib" path="lib/Logs/log4j-api-2.17.0.jar" sourcepath="lib/Logs/log4j-api-2.17.0-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-core-2.17.0.jar" sourcepath="lib/Logs/log4j-core-2.17.0-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-slf4j-impl-2.17.0.jar" sourcepath="lib/Logs/log4j-slf4j-impl-2.17.0-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.32.jar" sourcepath="lib/Logs/slf4j-api-1.7.32-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,13 +0,0 @@
# Log configuration
# #################
# priority setting: DEBUG < INFO < WARN < ERROR
log4j.rootLogger = INFO, console
log4j.logger.fr.devinsy.statoolinfos = 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} - StatoolInfos [%-5p] %34.34c.%25M - %m%n
log4j.appender.console.layout.ConversionPattern = %m%n

26
log4j2.properties Normal file
View file

@ -0,0 +1,26 @@
# Log configuration
# #################
# priority setting: DEBUG < INFO < WARN < ERROR
dest = err
name = Log4j2PropertiesConfig
status = ERROR
# Appenders settings.
appenders = console
appender.console.type = Console
appender.console.name = LogToConsole
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %m%n
# Logger settings.
rootLogger.level = INFO
rootLogger.appenderRefs = a
rootLogger.appenderRef.a.ref = LogToConsole
logger.statoolinfos.name = fr.devinsy.statoolinfos
logger.statoolinfos.level = INFO
logger.xidyn.name = fr.devinsy.xidyn
logger.xidyn.level = WARN

View file

@ -1,21 +0,0 @@
# Log configuration
# #################
# priority setting: DEBUG < INFO < WARN < ERROR
log4j.rootLogger = INFO, stdout, LogWriter
log4j.logger.fr.devinsy.statoolinfos = INFO
log4j.logger.fr.devinsy.xidyn = INFO
#--
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = %m%n
#--
log4j.appender.LogWriter = org.apache.log4j.RollingFileAppender
log4j.appender.LogWriter.File = /srv/StatoolInfos/tatoolinfos.log
log4j.appender.LogWriter.MaxFileSize = 100000KB
log4j.appender.LogWriter.MaxBackupIndex = 5
log4j.appender.LogWriter.layout = org.apache.log4j.PatternLayout
log4j.appender.LogWriter.layout.ConversionPattern = %d{ISO8601} - InfosStatool [%-5p] %34.34c.%-25M - %m%n

View file

@ -0,0 +1,26 @@
# Log configuration
# #################
# priority setting: DEBUG < INFO < WARN < ERROR
dest = err
name = Log4j2PropertiesConfig
status = ERROR
# Appenders settings.
appenders = console
appender.console.type = Console
appender.console.name = LogToConsole
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %m%n
# Logger settings.
rootLogger.level = INFO
rootLogger.appenderRefs = a
rootLogger.appenderRef.a.ref = LogToConsole
logger.statoolinfos.name = fr.devinsy.statoolinfos
logger.statoolinfos.level = INFO
logger.xidyn.name = fr.devinsy.xidyn
logger.xidyn.level = WARN

View file

@ -20,11 +20,9 @@ package fr.devinsy.statoolinfos;
import java.io.File;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.EnhancedPatternLayout;
import org.apache.log4j.Level;
import org.apache.log4j.PropertyConfigurator;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -56,14 +54,14 @@ public final class StatoolInfosLauncher
File loggerConfig = new File("log4j.properties");
if (loggerConfig.exists())
{
PropertyConfigurator.configure(loggerConfig.getAbsolutePath());
Configurator.initialize(null, loggerConfig.getAbsolutePath());
logger.info("Dedicated log configuration done.");
logger.info("Configuration file was found in [{}].", loggerConfig.getAbsoluteFile());
}
else
{
BasicConfigurator.configure(new ConsoleAppender(new EnhancedPatternLayout("%m%n")));
org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO);
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.INFO);
}
// Run.

View file

@ -18,9 +18,9 @@
*/
package fr.devinsy.statoolinfos.core;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -60,7 +60,7 @@ public class StatoolInfosTest
@BeforeClass
public static void beforeClass() throws StatoolInfosException
{
BasicConfigurator.configure();
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.DEBUG);
}
}

View file

@ -18,9 +18,9 @@
*/
package fr.devinsy.statoolinfos.metrics.http;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@ -72,7 +72,7 @@ public class UserAgentBotDetectorTest
@BeforeClass
public static void beforeClass() throws StatoolInfosException
{
BasicConfigurator.configure();
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.DEBUG);
}
}

View file

@ -20,9 +20,9 @@ package fr.devinsy.statoolinfos.metrics.http;
import java.time.LocalDateTime;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@ -271,7 +271,7 @@ public class VisitCountersTest
@BeforeClass
public static void beforeClass() throws StatoolInfosException
{
BasicConfigurator.configure();
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.DEBUG);
}
}