本文整理汇总了Java中com.alibaba.dubbo.common.logger.Logger类的典型用法代码示例。如果您正苦于以下问题:Java Logger类的具体用法?Java Logger怎么用?Java Logger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Logger类属于com.alibaba.dubbo.common.logger包,在下文中一共展示了Logger类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRpcException
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testRpcException() {
Logger logger = EasyMock.createMock(Logger.class);
RpcContext.getContext().setRemoteAddress("127.0.0.1", 1234);
RpcException exception = new RpcException("TestRpcException");
logger.error(EasyMock.eq("Got unchecked and undeclared exception which called by 127.0.0.1. service: " + DemoService.class.getName() + ", method: sayHello, exception: " + RpcException.class.getName() + ": TestRpcException"), EasyMock.eq(exception));
ExceptionFilter exceptionFilter = new ExceptionFilter(logger);
RpcInvocation invocation = new RpcInvocation("sayHello", new Class<?>[]{String.class}, new Object[]{"world"});
Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class);
EasyMock.expect(invoker.invoke(EasyMock.eq(invocation))).andThrow(exception);
EasyMock.replay(logger, invoker);
try {
exceptionFilter.invoke(invoker, invocation);
} catch (RpcException e) {
assertEquals("TestRpcException", e.getMessage());
}
EasyMock.verify(logger, invoker);
RpcContext.removeContext();
}
示例2: Log4jLoggerAdapter
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Log4jLoggerAdapter() {
try {
org.apache.log4j.Logger logger = LogManager.getRootLogger();
if (logger != null) {
Enumeration<Appender> appenders = logger.getAllAppenders();
if (appenders != null) {
while (appenders.hasMoreElements()) {
Appender appender = appenders.nextElement();
if (appender instanceof FileAppender) {
FileAppender fileAppender = (FileAppender)appender;
String filename = fileAppender.getFile();
file = new File(filename);
break;
}
}
}
}
} catch (Throwable t) {
}
}
示例3: Log4j2LoggerAdapter
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public Log4j2LoggerAdapter() {
try {
org.apache.logging.log4j.Logger logger = LogManager.getLogger();
if (logger != null) {
Map<String, Appender> appenderMap = ((org.apache.logging.log4j.core.Logger) logger).getAppenders();
for (Map.Entry<String, Appender> entry : appenderMap.entrySet()) {
if (entry.getValue() instanceof FileAppender) {
String filename = ((FileAppender) entry.getValue()).getFileName();
file = new File(filename);
break;
}
}
}
} catch (Throwable t) {
}
}
示例4: trace
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public static void trace(Logger logger, String msg) {
if (logger == null) {
return;
}
if (logger.isTraceEnabled()) {
logger.trace(msg);
}
}
示例5: info
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public static void info(Logger logger, Throwable e) {
if (logger == null) {
return;
}
if (logger.isInfoEnabled()) {
logger.info(e);
}
}
示例6: debug
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public static void debug(Logger logger, String msg) {
if (logger == null) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug(msg);
}
}
示例7: info
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public static void info(Logger logger, String msg) {
if (logger == null) {
return;
}
if (logger.isInfoEnabled()) {
logger.info(msg);
}
}
示例8: warn
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public static void warn(Logger logger, String msg, Throwable e) {
if (logger == null) {
return;
}
if (logger.isWarnEnabled()) {
logger.warn(msg, e);
}
}
示例9: debug
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public static void debug(Logger logger, String msg, Throwable e) {
if (logger == null) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug(msg, e);
}
}
示例10: error
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public static void error(Logger logger, Throwable e) {
if (logger == null) {
return;
}
if (logger.isErrorEnabled()) {
logger.error(e);
}
}
示例11: getLogger
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public Logger getLogger(Class<?> key) {
return new Log4jLogger(LogManager.getLogger(key));
}
示例12: getLogger
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public Logger getLogger(String key) {
return new Log4jLogger(LogManager.getLogger(key));
}
示例13: info
import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public static void info(Logger logger, String msg, Throwable e) {
if (logger == null) {
return;
}
if (logger.isInfoEnabled()) {
logger.info(msg, e);
}
}