use of org.apache.logging.log4j.message.Message in project logging-log4j2 by apache.
the class Category method l7dlog.
public void l7dlog(final Priority priority, final String key, final Throwable t) {
if (isEnabledFor(priority)) {
final Message msg = new LocalizedMessage(bundle, key, null);
forcedLog(FQCN, priority, msg, t);
}
}
use of org.apache.logging.log4j.message.Message in project logging-log4j2 by apache.
the class Category method l7dlog.
public void l7dlog(final Priority priority, final String key, final Object[] params, final Throwable t) {
if (isEnabledFor(priority)) {
final Message msg = new LocalizedMessage(bundle, key, params);
forcedLog(FQCN, priority, msg, t);
}
}
use of org.apache.logging.log4j.message.Message in project logging-log4j2 by apache.
the class Category method forcedLog.
public void forcedLog(final String fqcn, final Priority level, final Object message, final Throwable t) {
final org.apache.logging.log4j.Level lvl = org.apache.logging.log4j.Level.toLevel(level.toString());
final Message msg = message instanceof Message ? (Message) message : new ObjectMessage(message);
logger.logMessage(fqcn, lvl, null, msg, t);
}
use of org.apache.logging.log4j.message.Message in project logging-log4j2 by apache.
the class MessagePatternConverterTest method testPatternAndParameterizedMessageDateLookup.
@Test
public void testPatternAndParameterizedMessageDateLookup() throws Exception {
final MessagePatternConverter converter = MessagePatternConverter.newInstance(null, null);
final Message msg = new ParameterizedMessage("${date:now:buhu}");
final LogEvent event = //
Log4jLogEvent.newBuilder().setLoggerName(//
"MyLogger").setLevel(//
Level.DEBUG).setMessage(msg).build();
final StringBuilder sb = new StringBuilder();
converter.format(event, sb);
assertEquals("Unexpected result", "${date:now:buhu}", sb.toString());
}
use of org.apache.logging.log4j.message.Message in project logging-log4j2 by apache.
the class LevelPatternConverterTest method testLevelMapWithLengthAndLowerCase.
@Test
public void testLevelMapWithLengthAndLowerCase() {
final Message msg = new SimpleMessage("Hello");
LogEvent event = //
Log4jLogEvent.newBuilder().setLoggerName(//
"MyLogger").setLevel(//
Level.DEBUG).setMessage(msg).build();
final StringBuilder sb = new StringBuilder();
LevelPatternConverter converter = LevelPatternConverter.newInstance(null);
converter.format(event, sb);
assertEquals(Level.DEBUG.toString(), sb.toString());
final String[] opts = new String[] { "WARN=Warning, length=2, lowerCase=true" };
converter = LevelPatternConverter.newInstance(opts);
sb.setLength(0);
converter.format(event, sb);
assertEquals("de", sb.toString());
event = //
Log4jLogEvent.newBuilder().setLoggerName(//
"MyLogger").setLevel(//
Level.WARN).setMessage(msg).build();
sb.setLength(0);
converter.format(event, sb);
assertEquals("Warning", sb.toString());
}
Aggregations