use of org.apache.logging.log4j.test.TestLogger in project logging-log4j2 by apache.
the class LoggerTest method getFormatterLogger_Object.
@Test
public void getFormatterLogger_Object() {
// 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 TestLogger testLogger = (TestLogger) LogManager.getFormatterLogger(new TestStringFormatterMessageFactory());
assertNotNull(testLogger);
assertMessageFactoryInstanceOf(testLogger.getMessageFactory(), StringFormatterMessageFactory.class);
assertEqualMessageFactory(StringFormatterMessageFactory.INSTANCE, 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.test.TestLogger in project logging-log4j2 by apache.
the class LoggerTest method getFormatterLogger.
@Test
public void getFormatterLogger() {
// 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 TestLogger testLogger = (TestLogger) LogManager.getFormatterLogger();
final TestLogger altLogger = (TestLogger) LogManager.getFormatterLogger(getClass());
assertEquals(testLogger.getName(), altLogger.getName());
assertNotNull(testLogger);
assertMessageFactoryInstanceOf(testLogger.getMessageFactory(), StringFormatterMessageFactory.class);
assertEqualMessageFactory(StringFormatterMessageFactory.INSTANCE, 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.test.TestLogger in project logging-log4j2 by apache.
the class LoggerTest method getFormatterLogger_Class.
@Test
public void getFormatterLogger_Class() {
// 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 TestLogger testLogger = (TestLogger) LogManager.getFormatterLogger(TestStringFormatterMessageFactory.class);
assertNotNull(testLogger);
assertMessageFactoryInstanceOf(testLogger.getMessageFactory(), StringFormatterMessageFactory.class);
assertEqualMessageFactory(StringFormatterMessageFactory.INSTANCE, 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.test.TestLogger in project logging-log4j2 by apache.
the class LoggerTest method getLogger_Object_ParameterizedMessageFactory.
@Test
public void getLogger_Object_ParameterizedMessageFactory() {
// 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 ParameterizedMessageFactory messageFactory = ParameterizedMessageFactory.INSTANCE;
final TestLogger testLogger = (TestLogger) LogManager.getLogger(new TestParameterizedMessageFactory(), messageFactory);
assertNotNull(testLogger);
assertEqualMessageFactory(messageFactory, testLogger);
testLogger.debug("{}", Integer.MAX_VALUE);
assertEquals(1, testLogger.getEntries().size());
assertEquals(" DEBUG " + Integer.MAX_VALUE, testLogger.getEntries().get(0));
}
use of org.apache.logging.log4j.test.TestLogger in project logging-log4j2 by apache.
the class LoggerTest method getFormatterLogger_String.
@Test
public void getFormatterLogger_String() {
final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
final TestLogger testLogger = (TestLogger) LogManager.getFormatterLogger("getLogger_String_StringFormatterMessageFactory");
assertNotNull(testLogger);
assertMessageFactoryInstanceOf(testLogger.getMessageFactory(), StringFormatterMessageFactory.class);
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));
}
Aggregations