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


Java Log类代码示例

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


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

示例1: execute

import org.apache.commons.logging.Log; //导入依赖的package包/类
/**
* 执行一段文本
* @param expressString 程序文本
* @param context 执行上下文
* @param errorList 输出的错误信息List
* @param isCache 是否使用Cache中的指令集
* @param isTrace 是否输出详细的执行指令信息
* @param aLog 输出的log
* @return
* @throws Exception
*/
public Object execute(String expressString, IExpressContext<String,Object> context,
		List<String> errorList, boolean isCache, boolean isTrace, Log aLog)
		throws Exception {
	InstructionSet parseResult = null;
	if (isCache == true) {
		parseResult = expressInstructionSetCache.get(expressString);
		if (parseResult == null) {
			synchronized (expressInstructionSetCache) {
				parseResult = expressInstructionSetCache.get(expressString);
				if (parseResult == null) {
					parseResult = this.parseInstructionSet(expressString);
					expressInstructionSetCache.put(expressString,
							parseResult);
				}
			}
		}
	} else {
		parseResult = this.parseInstructionSet(expressString);
	}
	return  InstructionSetRunner.executeOuter(this,parseResult,this.loader,context, errorList,
		 	isTrace,false,aLog,false);
}
 
开发者ID:alibaba,项目名称:QLExpress,代码行数:34,代码来源:ExpressRunner.java

示例2: StreamPumper

import org.apache.commons.logging.Log; //导入依赖的package包/类
StreamPumper(final Log log, final String logPrefix,
    final InputStream stream, final StreamType type) {
  this.log = log;
  this.logPrefix = logPrefix;
  this.stream = stream;
  this.type = type;
  
  thread = new Thread(new Runnable() {
    @Override
    public void run() {
      try {
        pump();
      } catch (Throwable t) {
        ShellCommandFencer.LOG.warn(logPrefix +
            ": Unable to pump output from " + type,
            t);
      }
    }
  }, logPrefix + ": StreamPumper for " + type);
  thread.setDaemon(true);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:22,代码来源:StreamPumper.java

示例3: logThreadInfo

import org.apache.commons.logging.Log; //导入依赖的package包/类
/**
 * Log the current thread stacks at INFO level.
 * @param log the logger that logs the stack trace
 * @param title a descriptive title for the call stacks
 * @param minInterval the minimum time from the last 
 */
public static void logThreadInfo(Log log,
                                 String title,
                                 long minInterval) {
  boolean dumpStack = false;
  if (log.isInfoEnabled()) {
    synchronized (ReflectionUtils.class) {
      long now = Time.now();
      if (now - previousLogTime >= minInterval * 1000) {
        previousLogTime = now;
        dumpStack = true;
      }
    }
    if (dumpStack) {
      try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        printThreadInfo(new PrintStream(buffer, false, "UTF-8"), title);
        log.info(buffer.toString(Charset.defaultCharset().name()));
      } catch (UnsupportedEncodingException ignored) {
      }
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:29,代码来源:ReflectionUtils.java

示例4: logFailedRequest

import org.apache.commons.logging.Log; //导入依赖的package包/类
/**
 * Logs a request that failed
 */
static void logFailedRequest(Log logger, HttpUriRequest request, HttpHost host, Exception e) {
    if (logger.isDebugEnabled()) {
        logger.debug("request [" + request.getMethod() + " " + host + getUri(request.getRequestLine()) + "] failed", e);
    }
    if (tracer.isTraceEnabled()) {
        String traceRequest;
        try {
            traceRequest = buildTraceRequest(request, host);
        } catch (IOException e1) {
            tracer.trace("error while reading request for trace purposes", e);
            traceRequest = "";
        }
        tracer.trace(traceRequest);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:RequestLogger.java

示例5: internalGenerate

import org.apache.commons.logging.Log; //导入依赖的package包/类
/**
 * Generates the form.
 * 
 * @param item The object to generate a form for
 * @param fields Restricted list of fields to include
 * @param forcedFields List of fields to forcibly include
 * @param form The form object being generated
 * @param context Map representing optional context that can be used during
 *            retrieval of the form
 */
protected void internalGenerate(ItemType item, List<String> fields, List<String> forcedFields, Form form, Map<String, Object> context)
{
    Log log = getLogger();
    if (log.isDebugEnabled()) log.debug("Generating form for: " + item);

    // generate the form type and URI for the item.
    Item formItem = form.getItem();
    formItem.setType(getItemType(item));
    formItem.setUrl(getItemURI(item));

    Object itemData = makeItemData(item);
    FormCreationData data = new FormCreationDataImpl(itemData, forcedFields, context); 
    populateForm(form, fields, data);
    if (log.isDebugEnabled()) //
        log.debug("Generated form: " + form);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:FilteredFormProcessor.java

示例6: getNodeRefs

import org.apache.commons.logging.Log; //导入依赖的package包/类
/**
 * Converts a {@link String} containing a comma-separated list of {@link NodeRef} Ids into NodeRefs.
 * If a <code>logger</code> is supplied then invalid ids are logged as warnings.
 * @param values the {@link String} of {@link NodeRef} ids.
 * @param logger Log
 * @return A {@link List} of {@link NodeRef NodeRefs}.
 */
public static List<NodeRef> getNodeRefs(String values, Log logger)
{
    if(values==null || values.length()==0)
        return Collections.emptyList();
    String[] nodeRefIds = values.split(",");
    List<NodeRef> nodeRefs = new ArrayList<NodeRef>(nodeRefIds.length);
    for (String nodeRefString : nodeRefIds)
    {
        String nodeRefId = nodeRefString.trim();
        if (NodeRef.isNodeRef(nodeRefId))
        {
            NodeRef nodeRef = new NodeRef(nodeRefId);
            nodeRefs.add(nodeRef);
        }
        else if (logger!=null)
        {
            logNodeRefError(nodeRefId, logger);
        }
    }
    return nodeRefs;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:29,代码来源:NodeRef.java

示例7: isBlacklisted

import org.apache.commons.logging.Log; //导入依赖的package包/类
public static  boolean isBlacklisted(FiCaSchedulerApp application,
    FiCaSchedulerNode node, Log LOG) {
  if (application.isBlacklisted(node.getNodeName())) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Skipping 'host' " + node.getNodeName() + 
          " for " + application.getApplicationId() + 
          " since it has been blacklisted");
    }
    return true;
  }

  if (application.isBlacklisted(node.getRackName())) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Skipping 'rack' " + node.getRackName() + 
          " for " + application.getApplicationId() + 
          " since it has been blacklisted");
    }
    return true;
  }

  return false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:FiCaSchedulerUtils.java

示例8: oneTimeLiveLog

import org.apache.commons.logging.Log; //导入依赖的package包/类
/**
 * Logs each method routing path once per session.
 * 
 * @param logger
 * @param route
 */
static void oneTimeLiveLog(Log logger, ExtensionRoute route)
{
    synchronized (AJExtender.class)
    {
        if (oneTimeLogSet == null)
        {
            oneTimeLogSet = new ConcurrentHashSet<>();
        }
    }

    synchronized (oneTimeLogSet)
    {
        if (oneTimeLogSet.contains(route))
        {
            return;
        }
        else
        {
            logger.debug(route.toString());
            oneTimeLogSet.add(route);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:30,代码来源:AJExtender.java

示例9: isBlacklisted

import org.apache.commons.logging.Log; //导入依赖的package包/类
public static  boolean isBlacklisted(SchedulerApplicationAttempt application,
    SchedulerNode node, Log LOG) {
  if (application.isBlacklisted(node.getNodeName())) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Skipping 'host' " + node.getNodeName() +
          " for " + application.getApplicationId() +
          " since it has been blacklisted");
    }
    return true;
  }

  if (application.isBlacklisted(node.getRackName())) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Skipping 'rack' " + node.getRackName() +
          " for " + application.getApplicationId() +
          " since it has been blacklisted");
    }
    return true;
  }

  return false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:SchedulerAppUtils.java

示例10: doCreateLogger

import org.apache.commons.logging.Log; //导入依赖的package包/类
private static Log doCreateLogger(Class<?> logName) {
	Log logger;

	ClassLoader ccl = Thread.currentThread().getContextClassLoader();
	// push the logger class classloader (useful when dealing with commons-logging 1.0.x
	Thread.currentThread().setContextClassLoader(logName.getClassLoader());
	try {
		logger = LogFactory.getLog(logName);
	} catch (Throwable th) {
		logger = new SimpleLogger();
		logger
				.fatal(
						"logger infrastructure not properly set up. If commons-logging jar is used try switching to slf4j (see the FAQ for more info).",
						th);
	} finally {
		Thread.currentThread().setContextClassLoader(ccl);
	}
	return logger;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:20,代码来源:LogUtils.java

示例11: DefaultFrameworkTemplate

import org.apache.commons.logging.Log; //导入依赖的package包/类
public DefaultFrameworkTemplate(Object target, Log log) {
	if (OsgiPlatformDetector.isR42()) {
		Assert.isInstanceOf(Framework.class, target);
		fwk = (Framework) target;
	} else {
		throw new IllegalStateException("Cannot use OSGi 4.2 Framework API in an OSGi 4.1 environment");
	}
	this.log = log;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:10,代码来源:DefaultFrameworkTemplate.java

示例12: executeInnerOrigiInstruction

import org.apache.commons.logging.Log; //导入依赖的package包/类
public void executeInnerOrigiInstruction(RunEnvironment environmen,List<String> errorList,Log aLog) throws Exception{
			Instruction instruction =null;
		try {
			while (environmen.programPoint < this.instructionList.length) {
//				if (environmen.isExit() == true) {
//					return;
//				}
				instruction = this.instructionList[environmen.programPoint];
				instruction.setLog(aLog);// 设置log
				instruction.execute(environmen, errorList);
			}
		} catch (Exception e) {
			if (printInstructionError) {
				log.error("当前ProgramPoint = " + environmen.programPoint);
				log.error("当前指令" + instruction);
				log.error(e);
			}
			throw e;
		}
	}
 
开发者ID:alibaba,项目名称:QLExpress,代码行数:21,代码来源:InstructionSet.java

示例13: cleanup

import org.apache.commons.logging.Log; //导入依赖的package包/类
/**
 * Close the Closeable objects and <b>ignore</b> any {@link IOException} or 
 * null pointers. Must only be used for cleanup in exception handlers.
 *
 * @param log the log to record problems to at debug level. Can be null.
 * @param closeables the objects to close
 */
public static void cleanup(Log log, java.io.Closeable... closeables) {
  for (java.io.Closeable c : closeables) {
    if (c != null) {
      try {
        c.close();
      } catch(IOException e) {
        if (log != null && log.isDebugEnabled()) {
          log.debug("Exception in closing " + c, e);
        }
      }
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:IOUtils.java

示例14: cleanup

import org.apache.commons.logging.Log; //导入依赖的package包/类
/**
 * Close the Closeable objects and <b>ignore</b> any {@link IOException} or 
 * null pointers. Must only be used for cleanup in exception handlers.
 *
 * @param log the log to record problems to at debug level. Can be null.
 * @param closeables the objects to close
 */
public static void cleanup(Log log, java.io.Closeable... closeables) {
  for (java.io.Closeable c : closeables) {
    if (c != null) {
      try {
        c.close();
      } catch(Throwable e) {
        if (log != null && log.isDebugEnabled()) {
          log.debug("Exception in closing " + c, e);
        }
      }
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:21,代码来源:IOUtils.java

示例15: testLogExceptions

import org.apache.commons.logging.Log; //导入依赖的package包/类
@Test (timeout=300000)
public void testLogExceptions() throws Exception {
  final Configuration conf = new Configuration();
  final Call dummyCall = new Call(0, 0, null, null);
  Log logger = mock(Log.class);
  Server server = new Server("0.0.0.0", 0, LongWritable.class, 1, conf) {
    @Override
    public Writable call(
        RPC.RpcKind rpcKind, String protocol, Writable param,
        long receiveTime) throws Exception {
      return null;
    }
  };
  server.addSuppressedLoggingExceptions(TestException1.class);
  server.addTerseExceptions(TestException2.class);

  // Nothing should be logged for a suppressed exception.
  server.logException(logger, new TestException1(), dummyCall);
  verifyZeroInteractions(logger);

  // No stack trace should be logged for a terse exception.
  server.logException(logger, new TestException2(), dummyCall);
  verify(logger, times(1)).info(anyObject());

  // Full stack trace should be logged for other exceptions.
  final Throwable te3 = new TestException3();
  server.logException(logger, te3, dummyCall);
  verify(logger, times(1)).info(anyObject(), eq(te3));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:30,代码来源:TestServer.java


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