Log system v1 (to add to all classes)
This commit is contained in:
parent
7f5c60caad
commit
3f8094993e
50
NGCC/resources/log4j2.properties
Normal file
50
NGCC/resources/log4j2.properties
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
name=PropertiesConfig
|
||||||
|
property.filename = logs
|
||||||
|
appenders = console, file
|
||||||
|
|
||||||
|
|
||||||
|
# Création des appenders (interfaces) pour les sorties fichier et console
|
||||||
|
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}/ngcclogs.log
|
||||||
|
appender.file.layout.type=PatternLayout
|
||||||
|
appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
|
||||||
|
|
||||||
|
|
||||||
|
#Création des loggers
|
||||||
|
|
||||||
|
loggers = console, f, d
|
||||||
|
|
||||||
|
logger.f.name = fatalLogger
|
||||||
|
logger.f.level = fatal
|
||||||
|
logger.f.additivity = false
|
||||||
|
logger.f.appenderRefs = console
|
||||||
|
logger.f.appenderRef.console.ref = STDOUT
|
||||||
|
logger.f.appenderRef.file.ref = LOGFILE
|
||||||
|
|
||||||
|
logger.d.name = debugLogger
|
||||||
|
logger.d.level = debug
|
||||||
|
logger.d.additivity = false
|
||||||
|
logger.d.appenderRefs = console
|
||||||
|
logger.d.appenderRef.console.ref = STDOUT
|
||||||
|
logger.d.appenderRef.file.ref = LOGFILE
|
||||||
|
|
||||||
|
|
||||||
|
logger.console.name = log4j
|
||||||
|
logger.console.level = fatal
|
||||||
|
logger.console.additivity = false
|
||||||
|
logger.console.appenderRefs = console
|
||||||
|
logger.console.appenderRef.console.ref = STDOUT
|
||||||
|
logger.console.appenderRef.file.ref = LOGFILE
|
||||||
|
|
||||||
|
|
||||||
|
# Root Logger (par défaut)
|
||||||
|
rootLogger.level = debug
|
||||||
|
rootLogger.appenderRefs = stdout, file
|
||||||
|
rootLogger.appenderRef.stdout.ref = STDOUT
|
||||||
|
rootLogger.appenderRef.file.ref = LOGFILE
|
@ -41,7 +41,7 @@ public class Exec implements Callable <Void> {
|
|||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
|
|
||||||
// Système de subcommand semblable à celui de git permettant d'appeler les classes relatives
|
// Système de subcommand semblable à celui de git permettant d'appeler les classes relatives
|
||||||
String[] t = {"-r","-d","pdf"};
|
//String[] t = {"-r","-v1","-d","pdf"};
|
||||||
CommandLine cmd = new CommandLine (new Exec())
|
CommandLine cmd = new CommandLine (new Exec())
|
||||||
.addSubcommand("-r", new Read(System.out)) // nom commande, objet commande
|
.addSubcommand("-r", new Read(System.out)) // nom commande, objet commande
|
||||||
.addSubcommand("-b", new Build(System.out))
|
.addSubcommand("-b", new Build(System.out))
|
||||||
@ -51,7 +51,7 @@ public class Exec implements Callable <Void> {
|
|||||||
.addSubcommand("-e", new Evaluate(System.out))
|
.addSubcommand("-e", new Evaluate(System.out))
|
||||||
.addSubcommand("help", new HelpCommand()); // Aide générée automatiquement par l'API
|
.addSubcommand("help", new HelpCommand()); // Aide générée automatiquement par l'API
|
||||||
|
|
||||||
cmd.execute(t);
|
cmd.execute(args); //t
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,9 @@ import progressbar.ProgressBar;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import config.Config;
|
import config.Config;
|
||||||
import csv.GenerateCSV;
|
import csv.GenerateCSV;
|
||||||
import ocr.GestionnaireCopies;
|
import ocr.GestionnaireCopies;
|
||||||
@ -31,6 +34,8 @@ import ocr.GestionnaireCopies;
|
|||||||
|
|
||||||
public class Read implements Callable <Void> {
|
public class Read implements Callable <Void> {
|
||||||
|
|
||||||
|
private static Logger logger;
|
||||||
|
|
||||||
@Spec
|
@Spec
|
||||||
Model.CommandSpec spec;
|
Model.CommandSpec spec;
|
||||||
|
|
||||||
@ -67,7 +72,17 @@ public class Read implements Callable <Void> {
|
|||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
|
|
||||||
|
if (vb_level >= 0 && vb_level <=2) {
|
||||||
|
logger = LogManager.getFormatterLogger("fatalLogger");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger = LogManager.getFormatterLogger("debugLogger");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(help) {
|
if(help) {
|
||||||
|
logger.fatal("help command for -r used");
|
||||||
|
logger.debug("debug");
|
||||||
CommandLine.usage(this.spec, System.out);
|
CommandLine.usage(this.spec, System.out);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -93,6 +108,8 @@ public class Read implements Callable <Void> {
|
|||||||
|
|
||||||
//***************************************************
|
//***************************************************
|
||||||
|
|
||||||
|
logger.fatal("Read command executed");
|
||||||
|
logger.debug("Reading begin");
|
||||||
|
|
||||||
System.out.println("\nRead mode activated ...\n"); // Debug des paramètres à exploiter plus tard
|
System.out.println("\nRead mode activated ...\n"); // Debug des paramètres à exploiter plus tard
|
||||||
System.out.println("Update : "+step +"\n"+
|
System.out.println("Update : "+step +"\n"+
|
||||||
|
@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
class TestLog4j {
|
class TestLog4j {
|
||||||
|
|
||||||
|
|
||||||
private static Logger logger = LogManager.getLogger(LogManager.getLogger("ngccLog"));
|
private static Logger logger = LogManager.getFormatterLogger("log4j");
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
@ -22,4 +22,27 @@ class TestLog4j {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Idee verbosité
|
||||||
|
*
|
||||||
|
* Logger logger;
|
||||||
|
*
|
||||||
|
* if (v >= 0 && v <= 2) {
|
||||||
|
* logger = LogManager.getLogger(LogManager.getLogger("fatalLogger"));
|
||||||
|
* }
|
||||||
|
* else if (v >= 3 && v <= 4) {
|
||||||
|
* logger = LogManager.getLogger(LogManager.getLogger("errorLogger"));
|
||||||
|
* }
|
||||||
|
* else if (v >= 5 && v <= 6) {
|
||||||
|
* logger = LogManager.getLogger(LogManager.getLogger("warnLogger"));
|
||||||
|
* }
|
||||||
|
* else if (v >= 7 && v <= 8) {
|
||||||
|
* logger = LogManager.getLogger(LogManager.getLogger("infoLogger"));
|
||||||
|
* }
|
||||||
|
* else {
|
||||||
|
* logger = LogManager.getLogger(LogManager.getLogger("debugLogger"));
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* -> On met quand même logger.warn(...) et il apparaitra ou non selon le logger
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user