use of org.apache.log4j.spi.LocationInfo in project presto by prestodb.
the class JulAppender method append.
/**
* Append a log event at the appropriate JUL level, depending on the log4j level.
*/
@Override
protected void append(LoggingEvent loggingEvent) {
java.util.logging.Logger logger = java.util.logging.Logger.getLogger(loggingEvent.getLoggerName());
if (logger == null) {
LogLog.warn(format("Cannot obtain JUL %s. Verify that this appender is used while an appropriate LogManager is active.", loggingEvent.getLoggerName()));
return;
}
Level level = loggingEvent.getLevel();
java.util.logging.Level julLevel = convertLog4jLevel(level);
LogRecord record = new LogRecord(julLevel, loggingEvent.getRenderedMessage());
record.setMillis(loggingEvent.getTimeStamp());
LocationInfo location = loggingEvent.getLocationInformation();
if (location != null) {
record.setSourceClassName(location.getClassName());
record.setSourceMethodName(location.getMethodName());
}
logger.log(record);
}
Aggregations