Java Code Examples for org.slf4j.Logger.trace()

The following are Jave code examples for showing how to use trace() of the org.slf4j.Logger class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: cas4.0.x-server-wechat   File: LogAspect.java   View Source Code Vote up 6 votes
@Around("(execution (public * org.jasig.cas..*.*(..))) && !(execution( * org.jasig.cas..*.set*(..)))")
public Object traceMethod(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
    Object returnVal = null;
    final Logger logger = this.getLog(proceedingJoinPoint);
    final String methodName = proceedingJoinPoint.getSignature().getName();

    try {
        if (logger.isTraceEnabled()) {
            final Object[] args = proceedingJoinPoint.getArgs();
            final String arguments;
            if (args == null || args.length == 0) {
                arguments = "";
            } else {
                arguments = Arrays.deepToString(args);
            }
            logger.trace("Entering method [{}] with arguments [{}]", methodName, arguments);
        }
        returnVal = proceedingJoinPoint.proceed();
        return returnVal;
    } finally {
        logger.trace("Leaving method [{}] with return value [{}].", methodName,
                    (returnVal != null ? returnVal.toString() : "null"));
    }
}
 
Example 2
Project: MantaroRPG   File: SimpleLogToSLF4JAdapter.java   View Source Code Vote up 6 votes
@Override
public void onLog(SimpleLog simpleLog, SimpleLog.Level logLevel, Object message) {
	Logger log = convert(simpleLog);
	switch (logLevel) {
		case TRACE:
			if (log.isTraceEnabled()) {
				log.trace(message.toString());
			}
			break;
		case DEBUG:
			if (log.isDebugEnabled()) {
				log.debug(message.toString());
			}
			break;
		case INFO:
			log.info(message.toString());
			break;
		case WARNING:
			log.warn(message.toString());
			break;
		case FATAL:
			log.error(message.toString());
			break;
	}
}
 
Example 3
Project: incubator-ratis   File: LogUtils.java   View Source Code Vote up 6 votes
static <THROWABLE extends Throwable> void runAndLog(
    Logger log, CheckedRunnable<THROWABLE> op, Supplier<String> opName)
    throws THROWABLE {
  try {
    op.run();
  } catch (Throwable t) {
    if (log.isTraceEnabled()) {
      log.trace("Failed to " + opName.get(), t);
    } else if (log.isWarnEnabled()){
      log.warn("Failed to " + opName.get() + ": " + t);
    }
    throw t;
  }

  if (log.isTraceEnabled()) {
    log.trace("Successfully ran " + opName.get());
  }
}
 
Example 4
Project: incubator-ratis   File: LogUtils.java   View Source Code Vote up 6 votes
static <OUTPUT, THROWABLE extends Throwable> OUTPUT supplyAndLog(
    Logger log, CheckedSupplier<OUTPUT, THROWABLE> supplier, Supplier<String> name)
    throws THROWABLE {
  final OUTPUT output;
  try {
    output = supplier.get();
  } catch (Throwable t) {
    if (log.isTraceEnabled()) {
      log.trace("Failed to " + name.get(), t);
    } else if (log.isWarnEnabled()){
      log.warn("Failed to " + name.get() + ": " + t);
    }
    throw (THROWABLE)t;
  }

  if (log.isTraceEnabled()) {
    log.trace("Successfully supplied " + name.get());
  }
  return output;
}
 
Example 5
Project: lams   File: XMLObjectHelper.java   View Source Code Vote up 6 votes
/**
 * Marshall an XMLObject.  If the XMLObject already has a cached DOM via {@link XMLObject#getDOM()},
 * that Element will be returned.  Otherwise the object will be fully marshalled and that Element returned.
 * 
 * @param xmlObject the XMLObject to marshall
 * @return the marshalled Element
 * @throws MarshallingException if there is a problem marshalling the XMLObject
 */
public static Element marshall(XMLObject xmlObject) throws MarshallingException {
    Logger log = getLogger();
    log.debug("Marshalling XMLObject");
    
    if (xmlObject.getDOM() != null) {
        log.debug("XMLObject already had cached DOM, returning that element");
        return xmlObject.getDOM();
    }

    Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(xmlObject);
    if (marshaller == null) {
        log.error("Unable to marshall XMLOBject, no marshaller registered for object: "
                + xmlObject.getElementQName());
    }
    
    Element messageElem = marshaller.marshall(xmlObject);
    
    if (log.isTraceEnabled()) {
        log.trace("Marshalled XMLObject into DOM:");
        log.trace(XMLHelper.nodeToString(messageElem));
    }
    
    return messageElem;
}
 
Example 6
Project: openNaEF   File: LocationViewPage.java   View Source Code Vote up 6 votes
@Override
public void renew() {
    this.location.renew();
    this.nodes.clear();
    try {
        MplsNmsInventoryConnector conn = MplsNmsInventoryConnector.getInstance();
        Logger log = LoggerFactory.getLogger(LocationViewPage.class);
        for (NodeDto node : conn.getNodes()) {
            if (log.isTraceEnabled()) {
                log.trace("target: " + node.getName() + ":"
                        + (LocationUtil.getLocation(node) == null ?
                        "no-location" : LocationUtil.getLocation(node).getName()));
            }
            LocationDto loc = LocationUtil.getLocation(node);
            if (loc == null) {
                continue;
            } else if (DtoUtil.mvoEquals(this.location, loc)) {
                nodes.add(node);
            }
        }
    } catch (Exception e) {
        throw ExceptionUtils.throwAsRuntime(e);
    }
}
 
Example 7
Project: incubator-servicecomb-java-chassis   File: RollingMetricsFileOutput.java   View Source Code Vote up 5 votes
@Override
public void output(Map<String, String> metrics) {
  for (String metricName : metrics.keySet()) {
    Logger logger = allLoggers.computeIfAbsent(metricName, l -> LoggerFactory.getLogger(metricName));
    logger.trace(metrics.get(metricName));
  }
}
 
Example 8
Project: ait-platform   File: AitLogger.java   View Source Code Vote up 5 votes
/**
 * trace
 * @param logger
 * @param message
 * @param params
 */

public static void trace(Logger logger, String message, Object... params) {

	if (logger.isTraceEnabled()) {
		logger.trace(message, params);
	}
}
 
Example 9
Project: fuck_zookeeper   File: ZooTrace.java   View Source Code Vote up 5 votes
static public void logRequest(Logger log, long mask,
        char rp, Request request, String header)
{
    if (isTraceEnabled(log, mask)) {
        log.trace(header + ":" + rp + request.toString());
    }
}
 
Example 10
Project: lams   File: XMLObjectHelper.java   View Source Code Vote up 5 votes
/**
 * Unmarshall a Document from an InputSteam.
 * 
 * @param parserPool the ParserPool instance to use
 * @param inputStream the InputStream to unmarshall
 * @return the unmarshalled XMLObject
 * @throws XMLParserException if there is a problem parsing the input data
 * @throws UnmarshallingException if there is a problem unmarshalling the parsed DOM
 */
public static XMLObject unmarshallFromInputStream(ParserPool parserPool, InputStream inputStream)
        throws XMLParserException, UnmarshallingException {
    Logger log = getLogger();
    log.debug("Parsing InputStream into DOM document");

    Document messageDoc = parserPool.parse(inputStream);
    Element messageElem = messageDoc.getDocumentElement();

    if (log.isTraceEnabled()) {
        log.trace("Resultant DOM message was:");
        log.trace(XMLHelper.nodeToString(messageElem));
    }

    log.debug("Unmarshalling DOM parsed from InputStream");
    Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(messageElem);
    if (unmarshaller == null) {
        log.error("Unable to unmarshall InputStream, no unmarshaller registered for element "
                + XMLHelper.getNodeQName(messageElem));
        throw new UnmarshallingException(
                "Unable to unmarshall InputStream, no unmarshaller registered for element "
                        + XMLHelper.getNodeQName(messageElem));
    }

    XMLObject message = unmarshaller.unmarshall(messageElem);

    log.debug("InputStream succesfully unmarshalled");
    return message;
}
 
Example 11
Project: lams   File: XMLObjectHelper.java   View Source Code Vote up 5 votes
/**
 * Unmarshall a Document from a Reader.
 * 
 * @param parserPool the ParserPool instance to use
 * @param reader the Reader to unmarshall
 * @return the unmarshalled XMLObject
 * @throws XMLParserException if there is a problem parsing the input data
 * @throws UnmarshallingException if there is a problem unmarshalling the parsed DOM
 */
public static XMLObject unmarshallFromReader(ParserPool parserPool, Reader reader)
        throws XMLParserException, UnmarshallingException {
    Logger log = getLogger();
    log.debug("Parsing Reader into DOM document");
    

    Document messageDoc = parserPool.parse(reader);
    Element messageElem = messageDoc.getDocumentElement();

    if (log.isTraceEnabled()) {
        log.trace("Resultant DOM message was:");
        log.trace(XMLHelper.nodeToString(messageElem));
    }

    log.debug("Unmarshalling DOM parsed from Reader");
    Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(messageElem);
    if (unmarshaller == null) {
        log.error("Unable to unmarshall Reader, no unmarshaller registered for element "
                + XMLHelper.getNodeQName(messageElem));
        throw new UnmarshallingException(
                "Unable to unmarshall Reader, no unmarshaller registered for element "
                        + XMLHelper.getNodeQName(messageElem));
    }

    XMLObject message = unmarshaller.unmarshall(messageElem);

    log.debug("Reader succesfully unmarshalled");
    return message;
}
 
Example 12
Project: cerebro   File: LogWriter.java   View Source Code Vote up 5 votes
public static void write(Class clazz, LogLevel logLevel, String message) {
    Logger logger = LoggerFactory.getLogger(clazz);

    switch (logLevel) {
    case TRACE:
        logger.trace(message);
        break;
    case DEBUG:
        logger.debug(message);
        break;
    case INFO:
        logger.info(message);
        break;
    case WARN:
        logger.warn(message);
        break;
    case ERROR:
        logger.error(message);
        break;
    case FATAL:
        Marker marker = MarkerFactory.getMarker("FATAL");
        logger.error(marker, message);
        break;
    default:
        logger.warn("No suitable log level found");
        break;
    }
}
 
Example 13
Project: servicebuilder   File: LogUtil.java   View Source Code Vote up 5 votes
public static void doLog(String s, LogLevel logLevel, Logger logger) {
    switch (logLevel) {
        case ERROR: {
            logger.error(s);
            break;
        }

        case WARN: {
            logger.warn(s);
            break;
        }

        case INFO: {
            logger.info(s);
            break;
        }

        case DEBUG: {
            logger.debug(s);
            break;
        }

        case TRACE: {
            logger.trace(s);
            break;
        }

        default: {
            logger.error(s);
            break;
        }
    }
}
 
Example 14
Project: servicebuilder   File: LogUtil.java   View Source Code Vote up 5 votes
public static void doLog(String s, Throwable exception, LogLevel logLevel, Logger logger) {
    switch (logLevel) {
        case ERROR: {
            logger.error(s, exception);
            break;
        }

        case WARN: {
            logger.warn(s, exception);
            break;
        }

        case INFO: {
            logger.info(s, exception);
            break;
        }

        case DEBUG: {
            logger.debug(s, exception);
            break;
        }

        case TRACE: {
            logger.trace(s, exception);
            break;
        }

        default: {
            logger.error(s, exception);
            break;
        }
    }
}
 
Example 15
Project: soabase-stages   File: Slf4JTracing.java   View Source Code Vote up 4 votes
@Override
public void log(Logger logger, String str) {
    logger.trace(str);
}
 
Example 16
Project: fuck_zookeeper   File: ZooTrace.java   View Source Code Vote up 4 votes
public static void logTraceMessage(Logger log, long mask, String msg) {
    if (isTraceEnabled(log, mask)) {
        log.trace(msg);
    }
}
 
Example 17
Project: https-github.com-apache-zookeeper   File: ZooTrace.java   View Source Code Vote up 4 votes
public static void logTraceMessage(Logger log, long mask, String msg) {
    if (isTraceEnabled(log, mask)) {
        log.trace(msg);
    }
}
 
Example 18
Project: ZooKeeper   File: ZooTrace.java   View Source Code Vote up 4 votes
public static void logTraceMessage(Logger log, long mask, String msg) {
    if (isTraceEnabled(log, mask)) {
        log.trace(msg);
    }
}
 
Example 19
Project: monarch   File: ConnectorUtils.java   View Source Code Vote up 4 votes
public static void dumpConfiguration(Map<String, String> map, Logger log) {
  log.trace("Starting connector with configuration:");
  for (Map.Entry entry : map.entrySet()) {
    log.trace("{}: {}", entry.getKey(), entry.getValue());
  }
}
 
Example 20
Project: QDrill   File: AsmUtil.java   View Source Code Vote up 3 votes
/**
 * Write a class to the log.
 *
 * <p>
 * Writes at level TRACE.
 *
 * @param logger
 *          the logger to write to
 * @param logTag
 *          a tag to print to the log
 * @param classNode
 *          the class
 */
public static void logClass(final Logger logger, final String logTag, final ClassNode classNode) {
  if (logger.isTraceEnabled()) {
    logger.trace(logTag);
    final StringWriter stringWriter = new StringWriter();
    final PrintWriter printWriter = new PrintWriter(stringWriter);
    final TraceClassVisitor traceClassVisitor = new TraceClassVisitor(printWriter);
    classNode.accept(traceClassVisitor);
    logger.trace(stringWriter.toString());
  }
}