2019-09-27 00:32:16 +02:00
|
|
|
package log4j;
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
|
|
|
|
2019-10-04 10:49:13 +02:00
|
|
|
|
2019-09-27 00:32:16 +02:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
class TestLog4j {
|
|
|
|
|
|
|
|
|
2019-10-03 21:40:08 +02:00
|
|
|
private static Logger logger = LogManager.getFormatterLogger("log4j");
|
2019-09-27 00:32:16 +02:00
|
|
|
|
|
|
|
public static void main(String[] args) {
|
2019-09-27 10:35:38 +02:00
|
|
|
|
2019-09-27 00:32:16 +02:00
|
|
|
logger.debug("msg de debogage");
|
|
|
|
logger.info("msg d'information");
|
|
|
|
logger.warn("msg d'avertissement");
|
|
|
|
logger.error("msg d'erreur");
|
2019-09-27 10:35:38 +02:00
|
|
|
logger.fatal("msg d'erreur fatale");
|
|
|
|
|
2019-09-27 00:32:16 +02:00
|
|
|
}
|
2019-10-03 21:40:08 +02:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
*/
|
2019-09-27 00:32:16 +02:00
|
|
|
|
|
|
|
}
|