use of org.apache.logging.log4j.message.StringFormatterMessageFactory in project logging-log4j2 by apache.
the class LoggerTest method getLogger_String_StringFormatterMessageFactory.
@Test
public void getLogger_String_StringFormatterMessageFactory() {
final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
final TestLogger testLogger = (TestLogger) LogManager.getLogger("getLogger_String_StringFormatterMessageFactory", messageFactory);
assertNotNull(testLogger);
assertEqualMessageFactory(messageFactory, testLogger);
testLogger.debug("%,d", Integer.MAX_VALUE);
assertEquals(1, testLogger.getEntries().size());
assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
use of org.apache.logging.log4j.message.StringFormatterMessageFactory in project logging-log4j2 by apache.
the class LoggerTest method getLogger_Object_StringFormatterMessageFactory.
@Test
public void getLogger_Object_StringFormatterMessageFactory() {
// The TestLogger logger was already created in an instance variable for this class.
// The message factory is only used when the logger is created.
final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
final TestLogger testLogger = (TestLogger) LogManager.getLogger(new TestStringFormatterMessageFactory(), messageFactory);
assertNotNull(testLogger);
assertEqualMessageFactory(messageFactory, testLogger);
testLogger.debug("%,d", Integer.MAX_VALUE);
assertEquals(1, testLogger.getEntries().size());
assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
use of org.apache.logging.log4j.message.StringFormatterMessageFactory in project logging-log4j2 by apache.
the class FormatterLoggerBenchmark method up.
@Setup(Level.Trial)
public void up() {
new File("perftest.log").delete();
System.setProperty("log4j.configurationFile", "perf3PlainNoLoc.xml");
logger = LogManager.getLogger(getClass());
formatterLogger = LogManager.getLogger("formatter", new StringFormatterMessageFactory());
}
Aggregations