From 1328dbced03942e1c6be39e5857985433f39db9c Mon Sep 17 00:00:00 2001 From: Louis Calas Date: Fri, 27 Sep 2019 10:35:38 +0200 Subject: [PATCH] Maj --- NGCC/bin/log4j2.properties | 62 +++++++++++++------------------- NGCC/resources/log4j2.properties | 62 +++++++++++++------------------- NGCC/tests/log4j/TestLog4j.java | 4 ++- 3 files changed, 51 insertions(+), 77 deletions(-) diff --git a/NGCC/bin/log4j2.properties b/NGCC/bin/log4j2.properties index ac18c1e..ff7573d 100644 --- a/NGCC/bin/log4j2.properties +++ b/NGCC/bin/log4j2.properties @@ -1,38 +1,24 @@ -#status = error -#dest = err -#name = PropertiesConfig -# -#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 = %m%n -#appender.console.filter.threshold.type = ThresholdFilter -#appender.console.filter.threshold.level = error -# -#appender.rolling.type = RollingFile -#appender.rolling.name = RollingFile -#appender.rolling.fileName = ${filename} -#appender.rolling.filePattern = target/rolling2/test1-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz -#appender.rolling.layout.type = PatternLayout -#appender.rolling.layout.pattern = %d %p %C{1.} [%t] %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.rolling.name = com.example.my.app -#logger.rolling.level = debug -#logger.rolling.additivity = false -#logger.rolling.appenderRef.rolling.ref = RollingFile -# -#rootLogger.level = info -#rootLogger.appenderRef.stdout.ref = STDOUT \ No newline at end of file +name=PropertiesConfig +property.filename = logs +appenders = console, file + +appender.console.type = Console +appender.console.name = STDOUT +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n + +appender.file.type = File +appender.file.name = LOGFILE +appender.file.fileName=${filename}/propertieslogs.log +appender.file.layout.type=PatternLayout +appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n + +loggers=file +logger.file.name = NGCC +logger.file.level = debug +logger.file.appenderRefs = file +logger.file.appenderRef.file.ref = LOGFILE + +rootLogger.level = debug +rootLogger.appenderRefs = stdout +rootLogger.appenderRef.stdout.ref = STDOUT \ No newline at end of file diff --git a/NGCC/resources/log4j2.properties b/NGCC/resources/log4j2.properties index ac18c1e..ff7573d 100644 --- a/NGCC/resources/log4j2.properties +++ b/NGCC/resources/log4j2.properties @@ -1,38 +1,24 @@ -#status = error -#dest = err -#name = PropertiesConfig -# -#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 = %m%n -#appender.console.filter.threshold.type = ThresholdFilter -#appender.console.filter.threshold.level = error -# -#appender.rolling.type = RollingFile -#appender.rolling.name = RollingFile -#appender.rolling.fileName = ${filename} -#appender.rolling.filePattern = target/rolling2/test1-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz -#appender.rolling.layout.type = PatternLayout -#appender.rolling.layout.pattern = %d %p %C{1.} [%t] %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.rolling.name = com.example.my.app -#logger.rolling.level = debug -#logger.rolling.additivity = false -#logger.rolling.appenderRef.rolling.ref = RollingFile -# -#rootLogger.level = info -#rootLogger.appenderRef.stdout.ref = STDOUT \ No newline at end of file +name=PropertiesConfig +property.filename = logs +appenders = console, file + +appender.console.type = Console +appender.console.name = STDOUT +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n + +appender.file.type = File +appender.file.name = LOGFILE +appender.file.fileName=${filename}/propertieslogs.log +appender.file.layout.type=PatternLayout +appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n + +loggers=file +logger.file.name = NGCC +logger.file.level = debug +logger.file.appenderRefs = file +logger.file.appenderRef.file.ref = LOGFILE + +rootLogger.level = debug +rootLogger.appenderRefs = stdout +rootLogger.appenderRef.stdout.ref = STDOUT \ No newline at end of file diff --git a/NGCC/tests/log4j/TestLog4j.java b/NGCC/tests/log4j/TestLog4j.java index e803230..bd1410a 100644 --- a/NGCC/tests/log4j/TestLog4j.java +++ b/NGCC/tests/log4j/TestLog4j.java @@ -13,11 +13,13 @@ class TestLog4j { private static Logger logger = LogManager.getLogger(); public static void main(String[] args) { + logger.debug("msg de debogage"); logger.info("msg d'information"); logger.warn("msg d'avertissement"); logger.error("msg d'erreur"); - logger.fatal("msg d'erreur fatale"); + logger.fatal("msg d'erreur fatale"); + } }