本文整理汇总了Java中org.apache.log4j.Logger.isEnabledFor方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.isEnabledFor方法的具体用法?Java Logger.isEnabledFor怎么用?Java Logger.isEnabledFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.Logger
的用法示例。
在下文中一共展示了Logger.isEnabledFor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.log4j.Logger; //导入方法依赖的package包/类
@Override
public boolean execute(Context javascriptContext, Scriptable scope) throws EngineException {
if (isEnabled()) {
if (super.execute(javascriptContext, scope)) {
Logger log = engine ? Engine.logEngine : Engine.logContext;
if(level.equals(Level.WARN.toString()) && log.isEnabledFor(Level.WARN))
log.warn(getEvalString(javascriptContext, scope));
else if(level.equals(Level.INFO.toString()) && log.isInfoEnabled())
log.info(getEvalString(javascriptContext, scope));
else if(level.equals(Level.DEBUG.toString()) && log.isDebugEnabled())
log.debug(getEvalString(javascriptContext, scope));
else if(level.equals(Level.TRACE.toString()) && log.isTraceEnabled())
log.trace(getEvalString(javascriptContext, scope));
else if(level.equals(Level.ERROR.toString()) && log.isEnabledFor(Level.ERROR))
log.error(getEvalString(javascriptContext, scope));
return true;
}
}
return false;
}
示例2: stepExecute
import org.apache.log4j.Logger; //导入方法依赖的package包/类
@Override
protected boolean stepExecute(Context javascriptContext, Scriptable scope) throws EngineException {
if (isEnabled()) {
if (super.stepExecute(javascriptContext, scope)) {
Logger log = null;
if(logger.equals(Engine.logEngine.getName()))
log = Engine.logEngine;
else if(logger.equals(Engine.logContext.getName()))
log = Engine.logContext;
else if(logger.equals(Engine.logUser.getName()))
log = Engine.logUser;
else if(logger.equals(Engine.logAudit.getName()))
log = Engine.logAudit;
if(level.equals(Level.WARN.toString()) && log.isEnabledFor(Level.WARN))
log.warn(getEvalString(javascriptContext, scope));
else if(level.equals(Level.INFO.toString()) && log.isInfoEnabled())
log.info(getEvalString(javascriptContext, scope));
else if(level.equals(Level.DEBUG.toString()) && log.isDebugEnabled())
log.debug(getEvalString(javascriptContext, scope));
else if(level.equals(Level.TRACE.toString()) && log.isTraceEnabled())
log.trace(getEvalString(javascriptContext, scope));
else if(level.equals(Level.ERROR.toString()) && log.isEnabledFor(Level.ERROR))
log.error(getEvalString(javascriptContext, scope));
return true;
}
}
return false;
}