本文整理汇总了Java中org.apache.log4j.Logger.debug方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.debug方法的具体用法?Java Logger.debug怎么用?Java Logger.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.Logger
的用法示例。
在下文中一共展示了Logger.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logXml
import org.apache.log4j.Logger; //导入方法依赖的package包/类
public static void logXml(Document document, Logger log, String message) {
if (document != null && log.isInfoEnabled()) {
String xml = XMLUtils.prettyPrintDOM(document);
if (xml.length() > XMLUtils.MAX_XML_SIZE_FOR_LOG_INFO * 1000) {
if (!log.isDebugEnabled()) {
log.info(message
+ "\n[XML size is > " + XMLUtils.MAX_XML_SIZE_FOR_LOG_INFO
+ "KB, enable DEBUG log level for this logger to see it completly!]\n"
+ "[Extract limited to the first " + XMLUtils.MAX_XML_SIZE_FOR_LOG_INFO + "KB]\n"
+ xml.substring(0, XMLUtils.MAX_XML_SIZE_FOR_LOG_INFO * 1000)
+ "... (see the complete message in DEBUG log level)");
}
log.debug(message + ":\n" + xml);
} else {
log.info(message + ":\n" + xml);
}
}
}
示例2: 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;
}
示例3: main
import org.apache.log4j.Logger; //导入方法依赖的package包/类
public static void main(String[] args) {
Logger LOG = Logger.getLogger(LogFilesStructure.class);
ApplicationContext ctx = SpringApplication.run(Application.class, args);
LOG.debug("Spring Boot instantiated beans:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
LOG.debug(beanName);
}
LOG.info("\n....................................................." +
"\n.................Spring boot started................." +
"\n.....................................................\n");
}
示例4: logOnServer
import org.apache.log4j.Logger; //导入方法依赖的package包/类
@Override
public String logOnServer(LogRecord record) {
try {
if (iDeobfuscator != null && record.getThrown() != null)
iDeobfuscator.deobfuscateStackTrace(record.getThrown(), getPermutationStrongName());
Logger logger = Logger.getLogger(record.getLoggerName());
if (record.getLevel().intValue() >= Level.SEVERE.intValue()) {
logger.error(record.getMessage(), record.getThrown());
} else if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
logger.warn(record.getMessage(), record.getThrown());
} else if (record.getLevel().intValue() >= Level.INFO.intValue()) {
logger.info(record.getMessage(), record.getThrown());
} else if (record.getLevel().intValue() >= Level.FINE.intValue()) {
logger.debug(record.getMessage(), record.getThrown());
} else {
logger.trace(record.getMessage(), record.getThrown());
}
return null;
} catch (Exception e) {
sLogger.warn("Logging failed, reason: " + e.getMessage(), e);
}
return null;
}
示例5: log
import org.apache.log4j.Logger; //导入方法依赖的package包/类
private void log(LogMessage logMessage, LogLevel level, String loggerName) {
String logMessageString;
if (config.getLogInPlainString()) {
StringBuilder sb = new StringBuilder();
sb.append("[CID: ").append(logMessage.getCorrelationId());
if (StringUtils.isNotBlank(logMessage.getCorrelationIdLocal())) {
sb.append(" CID.Local: ").append(logMessage.getCorrelationIdLocal());
}
sb.append("] ").append(logMessage.getMessage());
String varsInString = LogHelper.variablesToString(logMessage.getVariables(), config.getLogVariableType());
if (varsInString.length() > 0) {
sb.append(" [").append(varsInString).append("]");
}
if (logMessage.getThrowable() != null) {
Throwable t = logMessage.getThrowable();
sb.append("\nException: ").append(ExceptionUtils.getMessage(t)).append(" ")
.append(ExceptionUtils.getStackTrace(logMessage.getThrowable()));
sb.append("");
}
logMessageString = sb.toString();
} else {
TimeZone tz = TimeZone.getTimeZone("UTC");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
df.setTimeZone(tz);
logMessage.setTimestamp(df.format(new Date()));
logMessage.setLevel(level.toString());
logMessage.setLogger(loggerName);
logMessage.setThread(Thread.currentThread().toString());
Gson gson = new GsonBuilder().disableHtmlEscaping().disableHtmlEscaping().create();
logMessageString = gson.toJson(logMessage);
}
Logger logger = LogManager.getLogger(loggerName);
switch (level) {
case INFO:
logger.info(logMessageString);
break;
case ERROR:
logger.error(logMessageString);
break;
case FATAL:
logger.fatal(logMessageString);
break;
case DEBUG:
logger.debug(logMessageString);
break;
}
}
示例6: flushLogs
import org.apache.log4j.Logger; //导入方法依赖的package包/类
/**
* From http://stackoverflow.com/a/3187802/42171
*/
public static void flushLogs(Logger logger) {
Logger root = Logger.getRootLogger();
Set<FileAppender> flushed = new HashSet<FileAppender>();
try {
for (Appender appender : CollectionUtil.iterable(logger.getAllAppenders(), Appender.class)) {
if (appender instanceof FileAppender) {
FileAppender fileAppender = (FileAppender)appender;
synchronized (fileAppender) {
if (!flushed.contains(fileAppender) && !fileAppender.getImmediateFlush()) {
root.info(String.format("Appender %s.%s is not doing an immediateFlush",
logger.getName(), appender.getName()));
fileAppender.setImmediateFlush(true);
logger.info("FLUSH");
fileAppender.setImmediateFlush(false);
flushed.add(fileAppender);
} else {
root.info(String.format("Appender %s.%s is doing an immediateFlush",
logger.getName(), appender.getName()));
}
} // SYNCH
} else {
root.debug(String.format("Unable to flush non-file appender %s.%s",
logger.getName(), appender.getName()));
}
} // FOR (appender)
} catch (Throwable ex) {
root.error("Failed flushing logs for " + logger, ex);
}
}
示例7: 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;
}
示例8: logMapDouble
import org.apache.log4j.Logger; //导入方法依赖的package包/类
/**
* Log map double.
*
* @param name the name
* @param h the h
* @param logger the logger
*/
public static void logMapDouble(String name, Map<String, Double> h, Logger logger) {
StringBuilder sber = new StringBuilder("{");
for (String k : h.keySet()) {
sber.append(k).append(":").append(h.get(k)).append(",");
}
sber.append("}");
logger.debug(name + " : " + sber);
}
示例9: logMapString
import org.apache.log4j.Logger; //导入方法依赖的package包/类
/**
* Log map string.
*
* @param name the name
* @param h the h
* @param logger the logger
*/
public static void logMapString(String name, Map<String, String> h, Logger logger) {
StringBuilder sb = new StringBuilder("{");
for (String k : h.keySet()) {
sb.append(k).append(":").append(h.get(k)).append(",");
}
sb.append("}");
logger.debug(name + " : " + sb);
}
示例10: logMapString
import org.apache.log4j.Logger; //导入方法依赖的package包/类
public static void logMapString(String name, Map<String, String> h, Logger logger) {
String logStr = "{";
for (String k : h.keySet()) {
logStr += k + ":" + h.get(k) + ",";
}
logStr += "}";
logger.debug(name + " : " + logStr);
}
示例11: printStack
import org.apache.log4j.Logger; //导入方法依赖的package包/类
public void printStack(Logger solverLogger){
if (solverLogger.isDebugEnabled()) {
ConstraintStackElement current = bottom;
if (current == null)
solverLogger.debug("<stack is empty>"); // Changed 2008.02.05
else {
int idx = 0;
while (current != null){
solverLogger.debug("stack element nr " + idx++ + " : " + current.expression); // Changed 2008.02.05
solverLogger.debug(" " + current.solutionCache.toString()); // Changed 2008.02.05
solverLogger.debug(" first noncontradictory system: " + current.getFirstNoncontradictorySystemIndex()); // Changed 2008.02.05
for (int systemIdx = 0; systemIdx < current.getNodeSystemCount(); systemIdx++){
if (current.getNodeSystemCount() > 1)
solverLogger.debug(" system " + systemIdx); // Changed 2008.02.05
ConstraintSystem system = current.getNodeSystem(systemIdx);
for (int setIdx = 0; setIdx < system.getConstraintSetCount(); setIdx++){
if (system.getConstraintSetCount() > 1)
solverLogger.debug(" set " + setIdx); // Changed 2008.02.05
SingleConstraintSet set = system.getConstraintSet(setIdx);
for (int constraintIdx = 0; constraintIdx < set.getConstraintCount(); constraintIdx++)
solverLogger.debug(" " + set.getConstraint(constraintIdx)); // Changed 2008.02.05
}
}
current = current.next;
}
}
}
}
示例12: loadReads
import org.apache.log4j.Logger; //导入方法依赖的package包/类
public static BigLong2ShortHashMap loadReads(File[] files, int k, int minSeqLen,
int availableProcessors, Logger logger)
throws ExecutionFailedException {
BigLong2ShortHashMap hm = new BigLong2ShortHashMap(
(int) (Math.log(availableProcessors) / Math.log(2)) + 4, 12, true);
ReadsLoadWorker[] workers = new ReadsLoadWorker[availableProcessors];
for (int i = 0; i < workers.length; ++i) {
workers[i] = new ReadsLoadWorker(hm, k, minSeqLen);
}
run(files, workers, hm, logger);
// calculating statistics...
int totalSeq = 0, goodSeq = 0;
long totalLen = 0, goodLen = 0;
for (ReadsLoadWorker worker : workers) {
totalSeq += worker.totalSeq;
goodSeq += worker.goodSeq;
totalLen += worker.totalLen;
goodLen += worker.goodLen;
}
Tool.debug(logger,
"Good/Total sequences count = " + NumUtils.groupDigits(goodSeq) + "/" + NumUtils.groupDigits(totalSeq)
+ " (" + String.format("%.1f", goodSeq * 100.0 / totalSeq) + "%)");
Tool.debug(logger,
"Good/Total sequences length = " + NumUtils.groupDigits(goodLen) + "/" + NumUtils.groupDigits(totalLen)
+ " (" + String.format("%.1f", goodLen * 100.0 / totalLen) + "%)");
logger.debug("k-mers HM size = " + NumUtils.groupDigits(hm.size()));
return hm;
}
示例13: log
import org.apache.log4j.Logger; //导入方法依赖的package包/类
/**
*
* Log the execution status
*
* @param uniqJobId - unique job id
* @param executionStatus - Execution status ({@link ExecutionStatus})
*/
public void log(String uniqJobId,ExecutionStatus executionStatus){
String header=null;
if(lastExecutionStatusMap.get(uniqJobId)==null){
lastExecutionStatusMap.put(uniqJobId, new LastExecutionStatus(0, executionStatus));
header = getHeader(executionStatus);
}else{
header = null;
if(executionStatus.equals(lastExecutionStatusMap.get(uniqJobId).getExecutionStatus())){
return;
}
lastExecutionStatusMap.put(uniqJobId, new LastExecutionStatus(lastExecutionStatusMap.get(uniqJobId).getStatusNumber() + 1, executionStatus));
}
Logger executionTrackingLogger = getExecutionStatusLogger(uniqJobId);
if(!StringUtils.isBlank(header)){
executionTrackingLogger.debug(header);
}
String executionStatusString = getExecutionStatusInString(executionStatus);
if(StringUtils.isBlank(executionStatusString)){
return;
}
executionTrackingLogger.debug(executionStatusString);
}
示例14: debugDump
import org.apache.log4j.Logger; //导入方法依赖的package包/类
/**
* Dumps debugging information into a logger.
*
* @param logger where to dump the information.
* @throws NullPointerException if {@code logger} is {@code null}.
*/
public void debugDump(final Logger logger) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
debugDump(pw);
final String str = sw.toString();
final String[] lines = str.split("\n");
for (final String line : lines) {
if (line.isEmpty()) {
continue;
}
logger.debug(line);
}
}
示例15: loadReads
import org.apache.log4j.Logger; //导入方法依赖的package包/类
public static BigLong2ShortHashMap loadReads(File[] files, int k, int minSeqLen,
int availableProcessors, Logger logger)
throws ExecutionFailedException {
BigLong2ShortHashMap hm = new BigLong2ShortHashMap(
(int) (Math.log(availableProcessors) / Math.log(2)) + 4, 12, true);
ReadsLoadWorker[] workers = new ReadsLoadWorker[availableProcessors];
for (int i = 0; i < workers.length; ++i) {
workers[i] = new ReadsLoadWorker(hm, k, minSeqLen, hash != null ? hash : new PolynomialHash());
}
run(files, workers, hm, logger);
// calculating statistics...
int totalSeq = 0, goodSeq = 0;
long totalLen = 0, goodLen = 0;
for (ReadsLoadWorker worker : workers) {
totalSeq += worker.totalSeq;
goodSeq += worker.goodSeq;
totalLen += worker.totalLen;
goodLen += worker.goodLen;
}
Tool.debug(logger,
"Good/Total sequences count = " + NumUtils.groupDigits(goodSeq) + "/" + NumUtils.groupDigits(totalSeq)
+ " (" + String.format("%.1f", goodSeq * 100.0 / totalSeq) + "%)");
Tool.debug(logger,
"Good/Total sequences length = " + NumUtils.groupDigits(goodLen) + "/" + NumUtils.groupDigits(totalLen)
+ " (" + String.format("%.1f", goodLen * 100.0 / totalLen) + "%)");
logger.debug("k-mers HM size = " + NumUtils.groupDigits(hm.size()));
return hm;
}