use of org.apache.log4j.PatternLayout in project cpsolver by UniTime.
the class Test method setupLogging.
/**
* Setup log4j logging
*
* @param logFile log file
* @param debug true if debug messages should be logged (use -Ddebug=true to enable debug message)
*/
public static void setupLogging(File logFile, boolean debug) {
Logger root = Logger.getRootLogger();
ConsoleAppender console = new ConsoleAppender(new PatternLayout("[%t] %m%n"));
console.setThreshold(Level.INFO);
root.addAppender(console);
if (logFile != null) {
try {
FileAppender file = new FileAppender(new PatternLayout("%d{dd-MMM-yy HH:mm:ss.SSS} [%t] %-5p %c{2}> %m%n"), logFile.getPath(), false);
file.setThreshold(Level.DEBUG);
root.addAppender(file);
} catch (IOException e) {
sLogger.fatal("Unable to configure logging, reason: " + e.getMessage(), e);
}
}
if (!debug)
root.setLevel(Level.INFO);
}
use of org.apache.log4j.PatternLayout in project cpsolver by UniTime.
the class Test method setupLogging.
/**
* Setup log4j logging
*
* @param logFile log file
*/
public static void setupLogging(File logFile) {
Logger root = Logger.getRootLogger();
ConsoleAppender console = new ConsoleAppender(new PatternLayout("[%t] %m%n"));
console.setThreshold(Level.INFO);
root.addAppender(console);
if (logFile != null) {
try {
FileAppender file = new FileAppender(new PatternLayout("%d{dd-MMM-yy HH:mm:ss.SSS} [%t] %-5p %c{2}> %m%n"), logFile.getPath(), false);
file.setThreshold(Level.DEBUG);
root.addAppender(file);
} catch (IOException e) {
sLog.fatal("Unable to configure logging, reason: " + e.getMessage(), e);
}
}
}
use of org.apache.log4j.PatternLayout in project intellij-community by JetBrains.
the class Runner method initLogger.
public static void initLogger() {
if (logger == null) {
long requiredFreeSpace = 1000000;
String logFolder = getDir(requiredFreeSpace);
FileAppender update = new FileAppender();
update.setFile(new File(logFolder, "idea_updater.log").getAbsolutePath());
update.setLayout(new PatternLayout("%d{dd MMM yyyy HH:mm:ss} %-5p %C{1}.%M - %m%n"));
update.setThreshold(Level.ALL);
update.setAppend(true);
update.activateOptions();
FileAppender updateError = new FileAppender();
updateError.setFile(new File(logFolder, "idea_updater_error.log").getAbsolutePath());
updateError.setLayout(new PatternLayout("%d{dd MMM yyyy HH:mm:ss} %-5p %C{1}.%M - %m%n"));
updateError.setThreshold(Level.ERROR);
updateError.setAppend(false);
updateError.activateOptions();
logger = Logger.getLogger("com.intellij.updater");
logger.addAppender(updateError);
logger.addAppender(update);
logger.setLevel(Level.ALL);
logger.info("--- Updater started ---");
}
}
use of org.apache.log4j.PatternLayout in project Activiti by Activiti.
the class MDCLoggingTest method setCustomLogger.
private void setCustomLogger() {
String PATTERN = "Modified Log *** ProcessDefinitionId=%X{mdcProcessDefinitionID} executionId=%X{mdcExecutionId} mdcProcessInstanceID=%X{mdcProcessInstanceID} mdcBusinessKey=%X{mdcBusinessKey} mdcTaskId=%X{mdcTaskId} %m%n";
console.setLayout(new PatternLayout(PATTERN));
console.setThreshold(Level.DEBUG);
console.activateOptions();
console.setName("MemoryAppender");
appenders = new ArrayList<Appender>();
Enumeration<?> appendersEnum = Logger.getRootLogger().getAllAppenders();
while (appendersEnum.hasMoreElements()) {
Appender object = (Appender) appendersEnum.nextElement();
appenders.add(object);
}
removeAppenders();
Logger.getRootLogger().addAppender(console);
}
use of org.apache.log4j.PatternLayout in project symmetric-ds by JumpMind.
the class SymRollingFileAppenderTest method getAppenderForTest.
protected SymRollingFileAppender getAppenderForTest(ByteArrayOutputStream os) throws Exception {
SymRollingFileAppender appender = new SymRollingFileAppender();
PatternLayout layout = new PatternLayout("%d %p [%X{engineName}] [%c{1}] [%t] %m%n");
appender.setLayout(layout);
appender.setOutputStream(os);
return appender;
}
Aggregations