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


Java Logger类代码示例

本文整理汇总了Java中org.apache.log.Logger的典型用法代码示例。如果您正苦于以下问题:Java Logger类的具体用法?Java Logger怎么用?Java Logger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Logger类属于org.apache.log包,在下文中一共展示了Logger类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logDetails

import org.apache.log.Logger; //导入依赖的package包/类
static void logDetails(Logger l, String s, String prio, Throwable t, String c) {
    if (prio.equalsIgnoreCase("OUT")) //$NON-NLS-1
    {
        printDetails(System.out, s, t, c);
    } else if (prio.equalsIgnoreCase("ERR")) //$NON-NLS-1
    {
        printDetails(System.err, s, t, c);
    } else {
        // N.B. if the string is not recognised, DEBUG is assumed
        Priority p = Priority.getPriorityForName(prio);
        if (log.isPriorityEnabled(p)) {// Thread method is potentially expensive
            String tn = Thread.currentThread().getName();
            StringBuilder sb = new StringBuilder(40);
            sb.append(tn);
            if (c.length()>0){
                sb.append(" ");
                sb.append(c);
            } else {
                sb.append(DEFAULT_SEPARATOR);
            }
            sb.append(s);
            log.log(p, sb.toString(), t);
        }
    }

}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:27,代码来源:LogFunction.java

示例2: close

import org.apache.log.Logger; //导入依赖的package包/类
public static void close(MessageConsumer closeable, Logger log){
    if (closeable != null){
        try {
            closeable.close();
        } catch (JMSException e) {
            log.error("Error during close: ", e);
        }
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:10,代码来源:Utils.java

示例3: tidyRMI

import org.apache.log.Logger; //导入依赖的package包/类
/**
 * Tidy up RMI access to allow JMeter client to exit.
 * Currently just interrups the "RMI Reaper" thread.
 * @param logger where to log the information
 */
public static void tidyRMI(Logger logger) {
    String reaperRE = JMeterUtils.getPropDefault("rmi.thread.name", "^RMI Reaper$");
    for(Thread t : Thread.getAllStackTraces().keySet()){
        String name = t.getName();
        if (name.matches(reaperRE)) {
            logger.info("Interrupting "+name);
            t.interrupt();
        }
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:16,代码来源:ClientJMeterEngine.java

示例4: populateBindings

import org.apache.log.Logger; //导入依赖的package包/类
/**
 * Populate variables to be passed to scripts
 * @param bindings Bindings
 */
protected void populateBindings(Bindings bindings) {
    final String label = getName();
    final String fileName = getFilename();
    final String scriptParameters = getParameters();
    // Use actual class name for log
    final Logger logger = LoggingManager.getLoggerForShortName(getClass().getName());
    bindings.put("log", logger);
    bindings.put("Label", label);
    bindings.put("FileName", fileName);
    bindings.put("Parameters", scriptParameters);
    String [] args=JOrphanUtils.split(scriptParameters, " ");//$NON-NLS-1$
    bindings.put("args", args);
    // Add variables for access to context and variables
    JMeterContext jmctx = JMeterContextService.getContext();
    bindings.put("ctx", jmctx);
    JMeterVariables vars = jmctx.getVariables();
    bindings.put("vars", vars);
    Properties props = JMeterUtils.getJMeterProperties();
    bindings.put("props", props);
    // For use in debugging:
    bindings.put("OUT", System.out);

    // Most subclasses will need these:
    Sampler sampler = jmctx.getCurrentSampler();
    bindings.put("sampler", sampler);
    SampleResult prev = jmctx.getPreviousResult();
    bindings.put("prev", prev);
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:33,代码来源:JSR223TestElement.java

示例5: initManager

import org.apache.log.Logger; //导入依赖的package包/类
protected void initManager(BSFManager mgr) throws BSFException{
    final String label = getName();
    final String fileName = getFilename();
    final String scriptParameters = getParameters();
    // Use actual class name for log
    final Logger logger = LoggingManager.getLoggerForShortName(getClass().getName());
    mgr.declareBean("log", logger, Logger.class); // $NON-NLS-1$
    mgr.declareBean("Label",label, String.class); // $NON-NLS-1$
    mgr.declareBean("FileName",fileName, String.class); // $NON-NLS-1$
    mgr.declareBean("Parameters", scriptParameters, String.class); // $NON-NLS-1$
    String [] args=JOrphanUtils.split(scriptParameters, " ");//$NON-NLS-1$
    mgr.declareBean("args",args,args.getClass());//$NON-NLS-1$
    // Add variables for access to context and variables
    JMeterContext jmctx = JMeterContextService.getContext();
    JMeterVariables vars = jmctx.getVariables();
    Properties props = JMeterUtils.getJMeterProperties();

    mgr.declareBean("ctx", jmctx, jmctx.getClass()); // $NON-NLS-1$
    mgr.declareBean("vars", vars, vars.getClass()); // $NON-NLS-1$
    mgr.declareBean("props", props, props.getClass()); // $NON-NLS-1$
    // For use in debugging:
    mgr.declareBean("OUT", System.out, PrintStream.class); // $NON-NLS-1$

    // Most subclasses will need these:
    Sampler sampler = jmctx.getCurrentSampler();
    mgr.declareBean("sampler", sampler, Sampler.class);
    SampleResult prev = jmctx.getPreviousResult();
    mgr.declareBean("prev", prev, SampleResult.class);
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:30,代码来源:BSFTestElement.java

示例6: testAdd1

import org.apache.log.Logger; //导入依赖的package包/类
public void testAdd1() throws Exception {
    Logger log = LoggingManager.getLoggerForClass();
    Collection<String> treePath = Arrays.asList(new String[] { "1", "2", "3", "4" });
    HashTree tree = new HashTree();
    log.debug("treePath = " + treePath);
    tree.add(treePath, "value");
    log.debug("Now treePath = " + treePath);
    log.debug(tree.toString());
    assertEquals(1, tree.list(treePath).size());
    assertEquals("value", tree.getArray(treePath)[0]);
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:12,代码来源:PackageTest.java

示例7: getLogger

import org.apache.log.Logger; //导入依赖的package包/类
@Override
protected Logger getLogger() {
    return log;
}
 
开发者ID:ptrd,项目名称:jmeter-websocket-samplers,代码行数:5,代码来源:TextFrameFilter.java

示例8: BeanShellInterpreter

import org.apache.log.Logger; //导入依赖的package包/类
/**
 *
 * @param init initialisation file
 * @param _log logger to pass to interpreter
 */
public BeanShellInterpreter(String init, Logger _log)  throws ClassNotFoundException {
    initFile = init;
    logger = _log;
    init();
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:11,代码来源:BeanShellInterpreter.java

示例9: getLogger

import org.apache.log.Logger; //导入依赖的package包/类
/**
 * Get a Logger instance which can be used by subclasses to log information.
 * This is the same Logger which is used by the base JavaSampler classes
 * (jmeter.protocol.java).
 *
 * @return a Logger instance which can be used for logging
 */
protected Logger getLogger() {
    return log;
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:11,代码来源:AbstractJavaSamplerClient.java

示例10: getLoggerForClass

import org.apache.log.Logger; //导入依赖的package包/类
/**
 * Get the Logger for a class - no argument needed because the calling class
 * name is derived automatically from the call stack.
 *
 * @return Logger
 */
public static Logger getLoggerForClass() {
    String className = new Exception().getStackTrace()[1].getClassName();
    return Hierarchy.getDefaultHierarchy().getLoggerFor(removePrefix(className));
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:11,代码来源:LoggingManager.java

示例11: getLoggerFor

import org.apache.log.Logger; //导入依赖的package包/类
/**
 * Get the Logger for a class.
 * 
 * @param category - the full name of the logger category
 *
 * @return Logger
 */
public static Logger getLoggerFor(String category) {
    return Hierarchy.getDefaultHierarchy().getLoggerFor(category);
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:11,代码来源:LoggingManager.java

示例12: getLoggerForShortName

import org.apache.log.Logger; //导入依赖的package包/类
/**
 * Get the Logger for a class.
 * 
 * @param category - the full name of the logger category, this will have the prefix removed.
 *
 * @return Logger
 */
public static Logger getLoggerForShortName(String category) {
    return Hierarchy.getDefaultHierarchy().getLoggerFor(removePrefix(category));
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:11,代码来源:LoggingManager.java

示例13: setTarget

import org.apache.log.Logger; //导入依赖的package包/类
/**
 * Set the logging target for a category.
 * 
 * @param target the LogTarget
 * @param category the category name
 */
public static void setTarget(LogTarget target, String category) {
    Logger logger = Hierarchy.getDefaultHierarchy().getLoggerFor(category);
    logger.setLogTargets(new LogTarget[] { target });
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:11,代码来源:LoggingManager.java

示例14: getLogger

import org.apache.log.Logger; //导入依赖的package包/类
abstract protected Logger getLogger(); 
开发者ID:ptrd,项目名称:jmeter-websocket-samplers,代码行数:2,代码来源:WebsocketSampler.java


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