MiddlewareLoggerImpl implements Logger { @Override public String getName() { return getLogger().getName(); } MiddlewareLoggerImpl(String name);  MiddlewareLoggerImpl(Class clazz); @Override String getName(); @Override boolean isDebugEnabled(); @Override void debug(String message); @Override void debug(String format, Object... args); @Override void debug(String message, Throwable t); @Override boolean isDebugEnabled(String appName); @Override void debugWithApp(String appName, String message); @Override void debugWithApp(String appName, String format, Object... args); @Override void debugWithApp(String appName, String message, Throwable t); @Override boolean isInfoEnabled(); @Override void info(String message); @Override void info(String format, Object... args); @Override void info(String message, Throwable t); @Override boolean isInfoEnabled(String appName); @Override void infoWithApp(String appName, String message); @Override void infoWithApp(String appName, String format, Object... args); @Override void infoWithApp(String appName, String message, Throwable t); @Override boolean isWarnEnabled(); @Override void warn(String message); @Override void warn(String format, Object... args); @Override void warn(String message, Throwable t); @Override boolean isWarnEnabled(String appName); @Override void warnWithApp(String appName, String message); @Override void warnWithApp(String appName, String format, Object... args); @Override void warnWithApp(String appName, String message, Throwable t); @Override boolean isErrorEnabled(); @Override void error(String message); @Override void error(String format, Object... args); @Override void error(String message, Throwable t); @Override boolean isErrorEnabled(String appName); @Override void errorWithApp(String appName, String message); @Override void errorWithApp(String appName, String format, Object... args); @Override void errorWithApp(String appName, String message, Throwable t);  }
@Test public void getName() throws Exception { Logger loggerFromClass = new MiddlewareLoggerImpl(MiddlewareLoggerImplTest.class); Logger logger = new MiddlewareLoggerImpl(MiddlewareLoggerImplTest.class.getCanonicalName()); Assert.assertEquals(loggerFromClass.getName(), logger.getName()); String appName = "app"; if (logger.isDebugEnabled()) { logger.debug("debug"); logger.debug("debug {}", "1"); logger.debug("debug {} {} {}", "1", "2", "3"); logger.debug("debug", new RuntimeException("runtime")); } if (logger.isDebugEnabled(appName)) { logger.debugWithApp(appName, "debug"); logger.debugWithApp(appName, "debug {}", "1"); logger.debugWithApp(appName, "debug {} {} {}", "1", "2", "3"); logger.debugWithApp(appName, "debug", new RuntimeException("runtime")); } if (logger.isInfoEnabled()) { logger.info("info"); logger.info("info {}", "1"); logger.info("info {} {} {}", "1", "2", "3"); logger.info("info", new RuntimeException("runtime")); } if (logger.isInfoEnabled(appName)) { logger.infoWithApp(appName, "info"); logger.infoWithApp(appName, "info {}", "1"); logger.infoWithApp(appName, "info {} {} {}", "1", "2", "3"); logger.infoWithApp(appName, "info", new RuntimeException("runtime")); } if (logger.isWarnEnabled()) { logger.warn("warn"); logger.warn("warn {}", "1"); logger.warn("warn {} {} {}", "1", "2", "3"); logger.warn("warn", new RuntimeException("runtime")); } if (logger.isWarnEnabled(appName)) { logger.warn(appName, "warn"); logger.warnWithApp(appName, "warn {}", "1"); logger.warnWithApp(appName, "warn {} {} {}", "1", "2", "3"); logger.warnWithApp(appName, "warn", new RuntimeException("runtime")); } if (logger.isErrorEnabled()) { logger.error("error"); logger.error("error {}", "1"); logger.error("error {} {} {}", "1", "2", "3"); logger.error("error", new RuntimeException("runtime")); } if (logger.isErrorEnabled(appName)) { logger.errorWithApp(appName, "error"); logger.errorWithApp(appName, "error {}", "1"); logger.errorWithApp(appName, "error {} {} {}", "1", "2", "3"); logger.errorWithApp(appName, "error", new RuntimeException("runtime")); } }