Java 类org.apache.logging.log4j.message.StringFormatterMessageFactory 实例源码

项目:log4j2    文件:LoggerTest.java   
@Test
public void getLogger_String_MessageFactoryMismatch() {
    final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
    final TestLogger testLogger = (TestLogger) LogManager.getLogger("getLogger_String_MessageFactoryMismatch",
            messageFactory);
    assertNotNull(testLogger);
    assertEquals(messageFactory, testLogger.getMessageFactory());
    final TestLogger testLogger2 = (TestLogger) LogManager.getLogger("getLogger_String_MessageFactoryMismatch",
            ParameterizedMessageFactory.INSTANCE);
    //TODO: How to test?
    //This test context always creates new loggers, other test context impls I tried fail other tests.
    //assertEquals(messageFactory, testLogger2.getMessageFactory());
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertEquals(1, testLogger.getEntries().size());
    assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
项目:log4j2    文件:SetLoggerTagTest.java   
@Test
public void testDoEndTagStringFactoryVarPageScope() throws Exception {
    this.tag.setLogger("testDoEndTagStringFactoryVarPageScope");

    final MessageFactory factory = new StringFormatterMessageFactory();

    this.tag.setFactory(factory);
    this.tag.setVar("goodbyeCruelWorld");

    assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
    assertNull("The default logger should still be null.", TagUtils.getDefaultLogger(this.context));

    final Object attribute = this.context.getAttribute("goodbyeCruelWorld", PageContext.PAGE_SCOPE);
    assertNotNull("The attribute should not be null.", attribute);
    assertTrue("The attribute should be a Log4jTaglibLogger.", attribute instanceof Log4jTaglibLogger);

    final Log4jTaglibLogger logger = (Log4jTaglibLogger)attribute;
    assertEquals("The logger name is not correct.", "testDoEndTagStringFactoryVarPageScope", logger.getName());
    assertSame("The message factory is not correct.", factory, logger.getMessageFactory());
}
项目:log4j2    文件:SetLoggerTagTest.java   
@Test
public void testDoEndTagStringFactoryVarApplicationScope() throws Exception {
    this.tag.setLogger("testDoEndTagStringFactoryVarApplicationScope");

    final MessageFactory factory = new StringFormatterMessageFactory();

    this.tag.setFactory(factory);
    this.tag.setVar("goodbyeCruelWorld");
    this.tag.setScope("application");

    assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
    assertNull("The default logger should still be null.", TagUtils.getDefaultLogger(this.context));

    final Object attribute = this.context.getAttribute("goodbyeCruelWorld", PageContext.APPLICATION_SCOPE);
    assertNotNull("The attribute should not be null.", attribute);
    assertTrue("The attribute should be a Log4jTaglibLogger.", attribute instanceof Log4jTaglibLogger);

    final Log4jTaglibLogger logger = (Log4jTaglibLogger)attribute;
    assertEquals("The logger name is not correct.", "testDoEndTagStringFactoryVarApplicationScope",
            logger.getName());
    assertSame("The message factory is not correct.", factory, logger.getMessageFactory());
}
项目:log4j2    文件:SetLoggerTagTest.java   
@Test
public void testDoEndTagStringFactoryDefault() throws Exception {
    this.tag.setLogger("testDoEndTagStringFactoryDefault");

    final MessageFactory factory = new StringFormatterMessageFactory();

    this.tag.setFactory(factory);

    assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());

    final Log4jTaglibLogger logger = TagUtils.getDefaultLogger(this.context);
    assertNotNull("The default logger should not be null anymore.", logger);
    assertEquals("The logger name is not correct.", "testDoEndTagStringFactoryDefault", logger.getName());
    assertSame("The message factory is not correct.", factory, logger.getMessageFactory());
}
项目:logging-log4j2    文件:LoggerTest.java   
@Test
public void getLogger_String_MessageFactoryMismatch() {
    final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
    final TestLogger testLogger = (TestLogger) LogManager.getLogger("getLogger_String_MessageFactoryMismatch",
            messageFactory);
    assertNotNull(testLogger);
    assertEqualMessageFactory(messageFactory, testLogger);
    final TestLogger testLogger2 = (TestLogger) LogManager.getLogger("getLogger_String_MessageFactoryMismatch",
            ParameterizedMessageFactory.INSTANCE);
    assertNotNull(testLogger2);
    //TODO: How to test?
    //This test context always creates new loggers, other test context impls I tried fail other tests.
    //assertEquals(messageFactory, testLogger2.getMessageFactory());
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertEquals(1, testLogger.getEntries().size());
    assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
项目:logging-log4j2    文件:SetLoggerTagTest.java   
@Test
public void testDoEndTagStringFactoryVarPageScope() throws Exception {
    this.tag.setLogger("testDoEndTagStringFactoryVarPageScope");

    final MessageFactory factory = new StringFormatterMessageFactory();

    this.tag.setFactory(factory);
    this.tag.setVar("goodbyeCruelWorld");

    assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
    assertNull("The default logger should still be null.", TagUtils.getDefaultLogger(this.context));

    final Object attribute = this.context.getAttribute("goodbyeCruelWorld", PageContext.PAGE_SCOPE);
    assertNotNull("The attribute should not be null.", attribute);
    assertTrue("The attribute should be a Log4jTaglibLogger.", attribute instanceof Log4jTaglibLogger);

    final Log4jTaglibLogger logger = (Log4jTaglibLogger)attribute;
    assertEquals("The logger name is not correct.", "testDoEndTagStringFactoryVarPageScope", logger.getName());
    checkMessageFactory("The message factory is not correct.", factory, logger);
}
项目:logging-log4j2    文件:SetLoggerTagTest.java   
@Test
public void testDoEndTagStringFactoryVarApplicationScope() throws Exception {
    this.tag.setLogger("testDoEndTagStringFactoryVarApplicationScope");

    final MessageFactory factory = new StringFormatterMessageFactory();

    this.tag.setFactory(factory);
    this.tag.setVar("goodbyeCruelWorld");
    this.tag.setScope("application");

    assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
    assertNull("The default logger should still be null.", TagUtils.getDefaultLogger(this.context));

    final Object attribute = this.context.getAttribute("goodbyeCruelWorld", PageContext.APPLICATION_SCOPE);
    assertNotNull("The attribute should not be null.", attribute);
    assertTrue("The attribute should be a Log4jTaglibLogger.", attribute instanceof Log4jTaglibLogger);

    final Log4jTaglibLogger logger = (Log4jTaglibLogger)attribute;
    assertEquals("The logger name is not correct.", "testDoEndTagStringFactoryVarApplicationScope",
            logger.getName());
    checkMessageFactory("The message factory is not correct.", factory, logger);
}
项目:logging-log4j2    文件:SetLoggerTagTest.java   
@Test
public void testDoEndTagStringFactoryDefault() throws Exception {
    this.tag.setLogger("testDoEndTagStringFactoryDefault");

    final MessageFactory factory = new StringFormatterMessageFactory();

    this.tag.setFactory(factory);

    assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());

    final Log4jTaglibLogger logger = TagUtils.getDefaultLogger(this.context);
    assertNotNull("The default logger should not be null anymore.", logger);
    assertEquals("The logger name is not correct.", "testDoEndTagStringFactoryDefault", logger.getName());
    checkMessageFactory("The message factory is not correct.", factory, logger);
}
项目:log4j2    文件:LoggerTest.java   
@Test
public void getLogger_Class_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 TestLogger testLogger = (TestLogger) LogManager.getLogger(TestStringFormatterMessageFactory.class,
            StringFormatterMessageFactory.INSTANCE);
    assertNotNull(testLogger);
    assertEquals(StringFormatterMessageFactory.INSTANCE, testLogger.getMessageFactory());
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertEquals(1, testLogger.getEntries().size());
    assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
项目:log4j2    文件:LoggerTest.java   
@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);
    assertTrue(testLogger.getMessageFactory() instanceof StringFormatterMessageFactory);
    assertEquals(StringFormatterMessageFactory.INSTANCE, testLogger.getMessageFactory());
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertEquals(1, testLogger.getEntries().size());
    assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
项目:log4j2    文件:LoggerTest.java   
@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);
    assertEquals(messageFactory, testLogger.getMessageFactory());
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertEquals(1, testLogger.getEntries().size());
    assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
项目:log4j2    文件:LoggerTest.java   
@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);
    assertTrue(testLogger.getMessageFactory() instanceof StringFormatterMessageFactory);
    assertEquals(StringFormatterMessageFactory.INSTANCE, testLogger.getMessageFactory());
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertEquals(1, testLogger.getEntries().size());
    assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
项目:log4j2    文件:LoggerTest.java   
@Test
public void getLogger_String_StringFormatterMessageFactory() {
    final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
    final TestLogger testLogger = (TestLogger) LogManager.getLogger("getLogger_String_StringFormatterMessageFactory",
            messageFactory);
    assertNotNull(testLogger);
    assertEquals(messageFactory, testLogger.getMessageFactory());
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertEquals(1, testLogger.getEntries().size());
    assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
项目:log4j2    文件:LoggerTest.java   
@Test
public void getFormatterLogger_String() {
    final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
    final TestLogger testLogger = (TestLogger) LogManager.getFormatterLogger("getLogger_String_StringFormatterMessageFactory");
    assertNotNull(testLogger);
    assertTrue(testLogger.getMessageFactory() instanceof StringFormatterMessageFactory);
    assertEquals(messageFactory, testLogger.getMessageFactory());
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertEquals(1, testLogger.getEntries().size());
    assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
项目:log4j2    文件:LoggerTest.java   
@Test
public void getLogger_String_MessageFactoryMismatch() {
    final Logger testLogger = testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatch",
        StringFormatterMessageFactory.INSTANCE, ParameterizedMessageFactory.INSTANCE);
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1);
    assertEquals(String.format("%,d", Integer.MAX_VALUE), list.strList.get(0));
}
项目:log4j2    文件:LoggerTest.java   
@Test
public void getLogger_String_MessageFactoryMismatchNull() {
    final Logger testLogger =  testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatchNull",
        StringFormatterMessageFactory.INSTANCE, null);
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1);
    assertEquals(String.format("%,d", Integer.MAX_VALUE), list.strList.get(0));
}
项目:log4j2    文件:LoggerTest.java   
@Test
public void getLogger_String_MessageFactoryMismatch() {
    final Logger testLogger = testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatch",
            StringFormatterMessageFactory.INSTANCE, ParameterizedMessageFactory.INSTANCE);
    testLogger.debug("%,d", Integer.MAX_VALUE);
    final List<LogEvent> events = app.getEvents();
    assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
    assertEquals(String.format("%,d", Integer.MAX_VALUE), events.get(0).getMessage().getFormattedMessage());
}
项目:log4j2    文件:LoggerTest.java   
@Test
public void getLogger_String_MessageFactoryMismatchNull() {
    final Logger testLogger =  testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatchNull", StringFormatterMessageFactory.INSTANCE, null);
    testLogger.debug("%,d", Integer.MAX_VALUE);
    final List<LogEvent> events = app.getEvents();
    assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
    assertEquals(String.format("%,d", Integer.MAX_VALUE), events.get(0).getMessage().getFormattedMessage());
}
项目:fastlogger    文件:Log4j20Benchmark.java   
public void setup( final Log4j20Benchmark b ) {
    logger = new AsyncLogger(
            b.loggerContext,
            "",
            StringFormatterMessageFactory.INSTANCE
    );
}
项目:logging-log4j2    文件:FormatterLoggerBenchmark.java   
@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());
}
项目:logging-log4j2    文件:LoggerTest.java   
@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));
}
项目:logging-log4j2    文件:LoggerTest.java   
@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));
}
项目:logging-log4j2    文件:LoggerTest.java   
@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));
}
项目:logging-log4j2    文件:LoggerTest.java   
@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));
}
项目:logging-log4j2    文件:LoggerTest.java   
@Test
public void getLogger_Class_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 TestLogger testLogger = (TestLogger) LogManager.getLogger(TestStringFormatterMessageFactory.class,
            StringFormatterMessageFactory.INSTANCE);
    assertNotNull(testLogger);
    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));
}
项目:logging-log4j2    文件:LoggerTest.java   
@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));
}
项目:logging-log4j2    文件:LoggerTest.java   
@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));
}
项目:logging-log4j2    文件:LoggerTest.java   
@Test
public void getLogger_String_MessageFactoryMismatch() {
    final Logger testLogger = testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatch",
        StringFormatterMessageFactory.INSTANCE, ParameterizedMessageFactory.INSTANCE);
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertThat(list.strList, hasSize(1));
    assertThat(list.strList, hasItem(String.format("%,d", Integer.MAX_VALUE)));
}
项目:logging-log4j2    文件:LoggerTest.java   
@Test
public void getLogger_String_MessageFactoryMismatchNull() {
    final Logger testLogger =  testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatchNull",
        StringFormatterMessageFactory.INSTANCE, null);
    testLogger.debug("%,d", Integer.MAX_VALUE);
    assertThat(list.strList, hasSize(1));
    assertThat(list.strList, hasItem(String.format("%,d", Integer.MAX_VALUE)));
}
项目:logging-log4j2    文件:LoggerTest.java   
@Test
public void getLogger_String_MessageFactoryMismatch() {
    final Logger testLogger = testMessageFactoryMismatch(testName.getMethodName(),
            StringFormatterMessageFactory.INSTANCE, ParameterizedMessageFactory.INSTANCE);
    testLogger.debug("%,d", Integer.MAX_VALUE);
    final List<LogEvent> events = app.getEvents();
    assertEventCount(events, 1);
    assertEquals(String.format("%,d", Integer.MAX_VALUE), events.get(0).getMessage().getFormattedMessage());
}
项目:logging-log4j2    文件:LoggerTest.java   
@Test
public void getLogger_String_MessageFactoryMismatchNull() {
    final Logger testLogger =  testMessageFactoryMismatch(testName.getMethodName(), StringFormatterMessageFactory.INSTANCE, null);
    testLogger.debug("%,d", Integer.MAX_VALUE);
    final List<LogEvent> events = app.getEvents();
    assertEventCount(events, 1);
    assertEquals(String.format("%,d", Integer.MAX_VALUE), events.get(0).getMessage().getFormattedMessage());
}
项目:log4j2    文件:LogManager.java   
/**
 * Returns a formatter Logger using the fully qualified name of the Class as the Logger name.
 * <p>
 * This logger let you use a {@link java.util.Formatter} string in the message to format parameters.
 * </p>
 * <p>
 * Short-hand for {@code getLogger(clazz, StringFormatterMessageFactory.INSTANCE)}
 * </p>
 *
 * @param clazz
 *            The Class whose name should be used as the Logger name.
 * @return The Logger, created with a {@link StringFormatterMessageFactory}
 * @see Logger#fatal(Marker, String, Object...)
 * @see Logger#fatal(String, Object...)
 * @see Logger#error(Marker, String, Object...)
 * @see Logger#error(String, Object...)
 * @see Logger#warn(Marker, String, Object...)
 * @see Logger#warn(String, Object...)
 * @see Logger#info(Marker, String, Object...)
 * @see Logger#info(String, Object...)
 * @see Logger#debug(Marker, String, Object...)
 * @see Logger#debug(String, Object...)
 * @see Logger#trace(Marker, String, Object...)
 * @see Logger#trace(String, Object...)
 * @see StringFormatterMessageFactory
 */
public static Logger getFormatterLogger(final Class<?> clazz) {
    return getLogger(clazz != null ? clazz.getName() : getClassName(2), StringFormatterMessageFactory.INSTANCE);
}
项目:log4j2    文件:LogManager.java   
/**
 * Returns a formatter Logger using the fully qualified name of the value's Class as the Logger name.
 * <p>
 * This logger let you use a {@link java.util.Formatter} string in the message to format parameters.
 * </p>
 * <p>
 * Short-hand for {@code getLogger(value, StringFormatterMessageFactory.INSTANCE)}
 * </p>
 *
 * @param value
 *            The value's whose class name should be used as the Logger name.
 * @return The Logger, created with a {@link StringFormatterMessageFactory}
 * @see Logger#fatal(Marker, String, Object...)
 * @see Logger#fatal(String, Object...)
 * @see Logger#error(Marker, String, Object...)
 * @see Logger#error(String, Object...)
 * @see Logger#warn(Marker, String, Object...)
 * @see Logger#warn(String, Object...)
 * @see Logger#info(Marker, String, Object...)
 * @see Logger#info(String, Object...)
 * @see Logger#debug(Marker, String, Object...)
 * @see Logger#debug(String, Object...)
 * @see Logger#trace(Marker, String, Object...)
 * @see Logger#trace(String, Object...)
 * @see StringFormatterMessageFactory
 */
public static Logger getFormatterLogger(final Object value) {
    return getLogger(value != null ? value.getClass().getName() : getClassName(2),
            StringFormatterMessageFactory.INSTANCE);
}
项目:log4j2    文件:LogManager.java   
/**
 * Returns a formatter Logger with the specified name.
 * <p>
 * This logger let you use a {@link java.util.Formatter} string in the message to format parameters.
 * </p>
 * <p>
 * Short-hand for {@code getLogger(name, StringFormatterMessageFactory.INSTANCE)}
 * </p>
 *
 * @param name The logger name. If null it will default to the name of the calling class.
 * @return The Logger, created with a {@link StringFormatterMessageFactory}
 * @see Logger#fatal(Marker, String, Object...)
 * @see Logger#fatal(String, Object...)
 * @see Logger#error(Marker, String, Object...)
 * @see Logger#error(String, Object...)
 * @see Logger#warn(Marker, String, Object...)
 * @see Logger#warn(String, Object...)
 * @see Logger#info(Marker, String, Object...)
 * @see Logger#info(String, Object...)
 * @see Logger#debug(Marker, String, Object...)
 * @see Logger#debug(String, Object...)
 * @see Logger#trace(Marker, String, Object...)
 * @see Logger#trace(String, Object...)
 * @see StringFormatterMessageFactory
 */
public static Logger getFormatterLogger(final String name) {
    return getLogger(name != null ? name : getClassName(2), StringFormatterMessageFactory.INSTANCE);
}
项目:logging-log4j2    文件:LogManager.java   
/**
 * Returns a formatter Logger using the fully qualified name of the Class as the Logger name.
 * <p>
 * This logger let you use a {@link java.util.Formatter} string in the message to format parameters.
 * </p>
 * <p>
 * Short-hand for {@code getLogger(clazz, StringFormatterMessageFactory.INSTANCE)}
 * </p>
 *
 * @param clazz The Class whose name should be used as the Logger name.
 * @return The Logger, created with a {@link StringFormatterMessageFactory}
 * @throws UnsupportedOperationException if {@code clazz} is {@code null} and the calling class cannot be
 *             determined.
 * @see Logger#fatal(Marker, String, Object...)
 * @see Logger#fatal(String, Object...)
 * @see Logger#error(Marker, String, Object...)
 * @see Logger#error(String, Object...)
 * @see Logger#warn(Marker, String, Object...)
 * @see Logger#warn(String, Object...)
 * @see Logger#info(Marker, String, Object...)
 * @see Logger#info(String, Object...)
 * @see Logger#debug(Marker, String, Object...)
 * @see Logger#debug(String, Object...)
 * @see Logger#trace(Marker, String, Object...)
 * @see Logger#trace(String, Object...)
 * @see StringFormatterMessageFactory
 */
public static Logger getFormatterLogger(final Class<?> clazz) {
    return getLogger(clazz != null ? clazz : StackLocatorUtil.getCallerClass(2),
            StringFormatterMessageFactory.INSTANCE);
}
项目:logging-log4j2    文件:LogManager.java   
/**
 * Returns a formatter Logger using the fully qualified name of the value's Class as the Logger name.
 * <p>
 * This logger let you use a {@link java.util.Formatter} string in the message to format parameters.
 * </p>
 * <p>
 * Short-hand for {@code getLogger(value, StringFormatterMessageFactory.INSTANCE)}
 * </p>
 *
 * @param value The value's whose class name should be used as the Logger name.
 * @return The Logger, created with a {@link StringFormatterMessageFactory}
 * @throws UnsupportedOperationException if {@code value} is {@code null} and the calling class cannot be
 *             determined.
 * @see Logger#fatal(Marker, String, Object...)
 * @see Logger#fatal(String, Object...)
 * @see Logger#error(Marker, String, Object...)
 * @see Logger#error(String, Object...)
 * @see Logger#warn(Marker, String, Object...)
 * @see Logger#warn(String, Object...)
 * @see Logger#info(Marker, String, Object...)
 * @see Logger#info(String, Object...)
 * @see Logger#debug(Marker, String, Object...)
 * @see Logger#debug(String, Object...)
 * @see Logger#trace(Marker, String, Object...)
 * @see Logger#trace(String, Object...)
 * @see StringFormatterMessageFactory
 */
public static Logger getFormatterLogger(final Object value) {
    return getLogger(value != null ? value.getClass() : StackLocatorUtil.getCallerClass(2),
            StringFormatterMessageFactory.INSTANCE);
}
项目:logging-log4j2    文件:LogManager.java   
/**
 * Returns a formatter Logger with the specified name.
 * <p>
 * This logger let you use a {@link java.util.Formatter} string in the message to format parameters.
 * </p>
 * <p>
 * Short-hand for {@code getLogger(name, StringFormatterMessageFactory.INSTANCE)}
 * </p>
 *
 * @param name The logger name. If null it will default to the name of the calling class.
 * @return The Logger, created with a {@link StringFormatterMessageFactory}
 * @throws UnsupportedOperationException if {@code name} is {@code null} and the calling class cannot be determined.
 * @see Logger#fatal(Marker, String, Object...)
 * @see Logger#fatal(String, Object...)
 * @see Logger#error(Marker, String, Object...)
 * @see Logger#error(String, Object...)
 * @see Logger#warn(Marker, String, Object...)
 * @see Logger#warn(String, Object...)
 * @see Logger#info(Marker, String, Object...)
 * @see Logger#info(String, Object...)
 * @see Logger#debug(Marker, String, Object...)
 * @see Logger#debug(String, Object...)
 * @see Logger#trace(Marker, String, Object...)
 * @see Logger#trace(String, Object...)
 * @see StringFormatterMessageFactory
 */
public static Logger getFormatterLogger(final String name) {
    return name == null ? getFormatterLogger(StackLocatorUtil.getCallerClass(2)) : getLogger(name,
            StringFormatterMessageFactory.INSTANCE);
}