Added log initialization.

This commit is contained in:
Christian Pierre MOMON 2016-05-24 16:39:05 +02:00
parent e04451b630
commit 42b3851369
2 changed files with 33 additions and 4 deletions

11
log4j.properties Normal file
View File

@ -0,0 +1,11 @@
# Log information (priority setting : DEBUG < INFO < WARN < ERROR)
# ################
log4j.rootLogger = INFO, CONSOLE
log4j.logger.org.dclermonte.siba = DEBUG
#--
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern = %d{ISO8601} - SIBA [%-5p] %34.34c.%25M - %m%n

View File

@ -19,8 +19,14 @@
*/ */
package org.dclermonte.siba; package org.dclermonte.siba;
import java.io.File;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.PropertyConfigurator;
import org.dclermonte.siba.cli.SibaCLI; import org.dclermonte.siba.cli.SibaCLI;
import org.dclermonte.siba.gui.SibaGUI; import org.dclermonte.siba.gui.SibaGUI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Siba public class Siba
{ {
@ -30,21 +36,33 @@ public class Siba
* *
* @param args * @param args
*/ */
private static final Logger logger = LoggerFactory.getLogger(Siba.class);
public static void main(final String[] args) public static void main(final String[] args)
{ {
// Configure log.
File loggerConfig = new File("log4j.properties");
if (loggerConfig.exists())
{
PropertyConfigurator.configure(loggerConfig.getAbsolutePath());
logger.info("Dedicated log configuration done.");
logger.info("Configuration file was found in [{}].", loggerConfig.getAbsoluteFile());
}
else
{
BasicConfigurator.configure();
logger.info("Basic log configuration done.");
logger.info("Configuration file was not found in [{}].", loggerConfig.getAbsoluteFile());
}
// Run.
if (args.length == 0) if (args.length == 0)
{ {
SibaGUI.run(); SibaGUI.run();
} }
else else
{ {
SibaCLI.run(args); SibaCLI.run(args);
} }
} }
} }