From a7d1f43f28aef92895fa4983a06f0ce5e907c09f Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 23 Jan 2020 09:07:38 +0100 Subject: [PATCH] Fixed log configuration. --- src/org/april/agirstatool/AgirStatoolLauncher.java | 3 ++- src/org/april/agirstatool/cli/AgiStatoolCLI.java | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/org/april/agirstatool/AgirStatoolLauncher.java b/src/org/april/agirstatool/AgirStatoolLauncher.java index df43213..dba642f 100644 --- a/src/org/april/agirstatool/AgirStatoolLauncher.java +++ b/src/org/april/agirstatool/AgirStatoolLauncher.java @@ -21,6 +21,7 @@ package org.april.agirstatool; import java.io.File; import org.apache.commons.lang3.ArrayUtils; +import org.apache.log4j.BasicConfigurator; import org.apache.log4j.PropertyConfigurator; import org.april.agirstatool.cli.AgiStatoolCLI; import org.april.agirstatool.demo.AgirStatool; @@ -59,7 +60,7 @@ public final class AgirStatoolLauncher } else { - // BasicConfigurator.configure(); + BasicConfigurator.configure(); // logger.info("Basic log configuration done."); // logger.info("Configuration file was not found in [{}].", // loggerConfig.getAbsoluteFile()); diff --git a/src/org/april/agirstatool/cli/AgiStatoolCLI.java b/src/org/april/agirstatool/cli/AgiStatoolCLI.java index 36cb667..5c38404 100644 --- a/src/org/april/agirstatool/cli/AgiStatoolCLI.java +++ b/src/org/april/agirstatool/cli/AgiStatoolCLI.java @@ -86,8 +86,9 @@ public final class AgiStatoolCLI else { BasicConfigurator.configure(); - logger.info("Basic log configuration done."); - logger.info("Configuration file was not found in [{}].", loggerConfig.getAbsoluteFile()); + // logger.info("Basic log configuration done."); + // logger.info("Configuration file was not found in [{}].", + // loggerConfig.getAbsoluteFile()); } // Run. @@ -175,9 +176,12 @@ public final class AgiStatoolCLI { // Apply -c parameter. File log4jfile = new File(configurationFile.getParentFile(), "log4j.properties"); - logger.info("Applying configuration file found in [{}].", log4jfile.getAbsoluteFile()); - PropertyConfigurator.configure(log4jfile.getAbsolutePath()); - logger.info("Configuration log configuration done."); + if (log4jfile.exists()) + { + logger.info("Applying configuration file found in [{}].", log4jfile.getAbsoluteFile()); + PropertyConfigurator.configure(log4jfile.getAbsolutePath()); + logger.info("Configuration log configuration done."); + } switch (command) {