use of org.apache.logging.log4j.message.Message in project logging-log4j2 by apache.
the class ApiLogger method log.
@Override
public void log(final LogRecord record) {
if (isFiltered(record)) {
return;
}
final org.apache.logging.log4j.Level level = LevelTranslator.toLevel(record.getLevel());
final Object[] parameters = record.getParameters();
final MessageFactory messageFactory = logger.getMessageFactory();
final Message message = parameters == null ? messageFactory.newMessage(record.getMessage()) : /* LOG4J2-1251: not formatted case */
messageFactory.newMessage(record.getMessage(), parameters);
final Throwable thrown = record.getThrown();
logger.logIfEnabled(FQCN, level, null, message, thrown);
}
use of org.apache.logging.log4j.message.Message in project logging-log4j2 by apache.
the class AbstractManager method log.
protected void log(final Level level, final String message, final Throwable throwable) {
final Message m = LOGGER.getMessageFactory().newMessage("{} {} {}: {}", getClass().getSimpleName(), getName(), message, throwable);
LOGGER.log(level, m, throwable);
}
use of org.apache.logging.log4j.message.Message in project logging-log4j2 by apache.
the class Logger method logMessage.
@Override
public void logMessage(final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) {
final Message msg = message == null ? new SimpleMessage(Strings.EMPTY) : message;
final ReliabilityStrategy strategy = privateConfig.loggerConfig.getReliabilityStrategy();
strategy.log(this, getName(), fqcn, marker, level, msg, t);
}
use of org.apache.logging.log4j.message.Message in project logging-log4j2 by apache.
the class GelfLayoutBenchmark method createLogEvent.
private static LogEvent createLogEvent() {
final Marker marker = null;
final String fqcn = "com.mycom.myproject.mypackage.MyClass";
final org.apache.logging.log4j.Level level = org.apache.logging.log4j.Level.DEBUG;
final Message message = new SimpleMessage(MESSAGE);
final Throwable t = null;
final StringMap mdc = null;
final ThreadContext.ContextStack ndc = null;
final String threadName = null;
final StackTraceElement location = null;
final long timestamp = 12345678;
return //
Log4jLogEvent.newBuilder().setLoggerName(//
"name(ignored)").setMarker(//
marker).setLoggerFqcn(//
fqcn).setLevel(//
level).setMessage(//
message).setThrown(//
t).setContextData(//
mdc).setContextStack(//
ndc).setThreadName(//
threadName).setSource(//
location).setTimeMillis(//
timestamp).build();
}
use of org.apache.logging.log4j.message.Message in project logging-log4j2 by apache.
the class TextEncoderHelperBenchmark method createLogEvent.
private static LogEvent createLogEvent() {
final Marker marker = null;
final String fqcn = "com.mycom.myproject.mypackage.MyClass";
final Level level = Level.DEBUG;
final Message message = new SimpleMessage(STR);
final Throwable t = null;
final StringMap mdc = null;
final ContextStack ndc = null;
final String threadName = null;
final StackTraceElement location = null;
final long timestamp = 12345678;
return //
Log4jLogEvent.newBuilder().setLoggerName(//
"name(ignored)").setMarker(//
marker).setLoggerFqcn(//
fqcn).setLevel(//
level).setMessage(//
message).setThrown(//
t).setContextData(//
mdc).setContextStack(//
ndc).setThreadName(//
threadName).setSource(//
location).setTimeMillis(//
timestamp).build();
}
Aggregations