use of org.apache.log4j.Layout in project traccar by tananaev.
the class Log method setupLogger.
public static void setupLogger(Config config) throws IOException {
Layout layout = new PatternLayout("%d{" + DATE_FORMAT + "} %5p: %m%n");
Appender appender = new DailyRollingFileAppender(layout, config.getString("logger.file"), "'.'yyyyMMdd");
LogManager.resetConfiguration();
LogManager.getRootLogger().addAppender(new NullAppender());
logger = Logger.getLogger(LOGGER_NAME);
logger.addAppender(appender);
logger.setLevel(Level.toLevel(config.getString("logger.level"), Level.ALL));
// Workaround for "Bug 745866 - (EDG-45) Possible netty logging config problem"
InternalLoggerFactory.setDefaultFactory(new InternalLoggerFactory() {
@Override
public InternalLogger newInstance(String string) {
return new NettyInternalLogger();
}
});
Log.logSystemInfo();
Log.info("Version: " + getAppVersion());
}
use of org.apache.log4j.Layout in project scheduling by ow2-proactive.
the class Log4JTaskLogs method getStdoutLogs.
/**
* @see org.ow2.proactive.scheduler.common.task.TaskLogs#getStdoutLogs(boolean
* timeStamp)
*/
public synchronized String getStdoutLogs(boolean timeStamp) {
restoreEvents();
StringBuffer logs = new StringBuffer();
Layout l = getTaskLogLayout();
for (LoggingEvent e : this.allEvents) {
if (Log4JTaskLogs.STDOUT_LEVEL.equals(e.getLevel())) {
appendEventToLogs(e, logs, l, timeStamp);
}
}
return logs.toString();
}
use of org.apache.log4j.Layout in project scheduling by ow2-proactive.
the class Log4JTaskLogs method getAllLogs.
/**
* @see org.ow2.proactive.scheduler.common.task.TaskLogs#getAllLogs(boolean
* timeStamp)
*/
public synchronized String getAllLogs(boolean timeStamp) {
restoreEvents();
StringBuffer logs = new StringBuffer(this.allEvents.size());
Layout l = getTaskLogLayout();
for (LoggingEvent e : this.allEvents) {
appendEventToLogs(e, logs, l, timeStamp);
}
return logs.toString();
}
use of org.apache.log4j.Layout in project scheduling by ow2-proactive.
the class Log4JTaskLogs method getStderrLogs.
/**
* @see org.ow2.proactive.scheduler.common.task.TaskLogs#getStderrLogs(boolean
* timeStamp)
*/
public synchronized String getStderrLogs(boolean timeStamp) {
restoreEvents();
StringBuffer logs = new StringBuffer();
Layout l = getTaskLogLayout();
for (LoggingEvent e : this.allEvents) {
if (Log4JTaskLogs.STDERR_LEVEL.equals(e.getLevel())) {
appendEventToLogs(e, logs, l, timeStamp);
}
}
return logs.toString();
}
Aggregations