当前位置: 首页>>代码示例>>Java>>正文


Java Logger类代码示例

本文整理汇总了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();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:24,代码来源:ExceptionFilterTest.java

示例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) {
       }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:Log4jLoggerAdapter.java

示例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) {
	}
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:17,代码来源:Log4j2LoggerAdapter.java

示例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);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:10,代码来源:LogHelper.java

示例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);
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:10,代码来源:LogHelper.java

示例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);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:10,代码来源:LogHelper.java

示例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);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:10,代码来源:LogHelper.java

示例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);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:10,代码来源:LogHelper.java

示例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);
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:10,代码来源:LogHelper.java

示例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);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:10,代码来源:LogHelper.java

示例11: getLogger

import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public Logger getLogger(Class<?> key) {
	return new Log4jLogger(LogManager.getLogger(key));
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:4,代码来源:Log4jLoggerAdapter.java

示例12: getLogger

import com.alibaba.dubbo.common.logger.Logger; //导入依赖的package包/类
public Logger getLogger(String key) {
	return new Log4jLogger(LogManager.getLogger(key));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:4,代码来源:Log4jLoggerAdapter.java

示例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);
    }
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:10,代码来源:LogHelper.java


注:本文中的com.alibaba.dubbo.common.logger.Logger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。