Java Code Examples for org.slf4j.Logger#trace()
The following examples show how to use
org.slf4j.Logger#trace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Slf4jEventSender.java From cxf with Apache License 2.0 | 6 votes |
/** * Override this to easily change the logging level etc. */ protected void performLogging(Logger log, Marker marker, String logMessage) { if (loggingLevel == Level.INFO) { log.info(marker, logMessage); } else if (loggingLevel == Level.DEBUG) { log.debug(marker, logMessage); } else if (loggingLevel == Level.ERROR) { log.error(marker, logMessage); } else if (loggingLevel == Level.TRACE) { log.trace(marker, logMessage); } else if (loggingLevel == Level.WARN) { log.warn(marker, logMessage); } else { log.info(marker, logMessage); } }
Example 2
Source File: JsonObjectFileHelper.java From Singularity with Apache License 2.0 | 6 votes |
public boolean writeObject(Object object, Path path, Logger log) { final long start = System.currentTimeMillis(); try { final byte[] bytes = objectMapper.writeValueAsBytes(object); log.info("Writing {} bytes of {} to {}", bytes.length, object, path); Files.write( path, bytes, StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING ); return true; } catch (Throwable t) { log.error("Failed writing {}", object, t); return false; } finally { log.trace("Finishing writing {} after {}", object, JavaUtils.duration(start)); } }
Example 3
Source File: VariableLevelLog.java From data-prep with Apache License 2.0 | 6 votes |
/** * Log at the specified level. If the "logger" is null, nothing is logged. * If the "level" is null, nothing is logged. If the "format" or the "argArray" * are null, behaviour depends on the SLF4J-backing implementation. */ public static void log(Logger logger, Level level, String format, Object[] argArray) { if (logger != null && level != null) { switch (level) { case TRACE: logger.trace(format, argArray); break; case DEBUG: logger.debug(format, argArray); break; case INFO: logger.info(format, argArray); break; case WARN: logger.warn(format, argArray); break; case ERROR: logger.error(format, argArray); break; } } }
Example 4
Source File: LoggerSpaceFactory4LogbackBuilderTest.java From sofa-common-tools with Apache License 2.0 | 6 votes |
@Test public void testLoggingLevelDefaultInfo() { // System.clearProperty(Constants.LOG_LEVEL_PREFIX + "com.alipay.sofa.rpc"); AbstractLoggerSpaceFactory loggerSpaceFactory = loggerSpaceFactory4LogbackBuilder.build( "com.alipay.sofa.rpc", this.getClass().getClassLoader()); Logger logger = loggerSpaceFactory.getLogger("com.foo.Bar"); logger.info("info info info info "); logger.debug("debug debug debug debug "); logger.trace("trace trace trace trace"); Assert.assertTrue(logger.isInfoEnabled()); Assert.assertFalse(logger.isDebugEnabled()); logger.info("info level==="); }
Example 5
Source File: XMLObjectHelper.java From lams with GNU General Public License v2.0 | 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 6
Source File: RxIris.java From arcusplatform with Apache License 2.0 | 5 votes |
private static <T> void dolog(final LogLevel level, final Logger log, final String format, Object... value) { switch (level) { case TRACE: if (log.isTraceEnabled()) log.trace(format, value); break; case DEBUG: if (log.isDebugEnabled()) log.debug(format, value); break; case INFO: if (log.isInfoEnabled()) log.info(format, value); break; case WARN: if (log.isWarnEnabled()) log.warn(format, value); break; case ERROR: if (log.isErrorEnabled()) log.error(format, value); break; default: break; } }
Example 7
Source File: C_Message.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
@Override public void debug(Logger logger) { logger.debug("=== C_Message === "); logger.trace("\tRAW: {}", this.getPayload()); logger.debug("DeviceType: {}", deviceType.toString()); logger.debug("SerialNumber: {}", serialNumber); logger.debug("RFAddress: {}", rfAddress); }
Example 8
Source File: Slf4jSessionLogger.java From testgrid with Apache License 2.0 | 5 votes |
@Override public void log(SessionLogEntry entry) { if (!shouldLog(entry.getLevel(), entry.getNameSpace())) { return; } Logger logger = getLogger(entry.getNameSpace()); LogLevel logLevel = getLogLevel(entry.getLevel()); StringBuilder message = new StringBuilder(); message.append(getSupplementDetailString(entry)); message.append(formatMessage(entry)); switch (logLevel) { case TRACE: logger.trace(message.toString()); break; case DEBUG: logger.debug(message.toString()); break; case WARN: logger.warn(message.toString()); break; case ERROR: logger.error(message.toString()); break; default : logger.info(message.toString()); break; } }
Example 9
Source File: LoggingResourceFilter.java From brooklyn-server with Apache License 2.0 | 5 votes |
private void log(Logger logger, LogLevel level, String msg) { switch (level) { case TRACE: logger.trace(msg); break; case DEBUG: logger.debug(msg); break; case INFO: logger.info(msg); break; default: throw new IllegalStateException("Unexpected log level: "+level); } }
Example 10
Source File: GFToSlf4jBridge.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
@Override public void put(int level, String msg, Throwable exception) { Logger log = getLogger(); MDC.put("tid", Long.toHexString(Thread.currentThread().getId())); switch (level) { case SEVERE_LEVEL: case ERROR_LEVEL: log.error(msg, exception); break; case WARNING_LEVEL: log.warn(msg, exception); break; case INFO_LEVEL: case CONFIG_LEVEL: log.info(msg, exception); break; case FINE_LEVEL: log.debug(msg, exception); break; case FINER_LEVEL: case FINEST_LEVEL: log.trace(msg, exception); break; default: log.debug(msg, exception); break; } }
Example 11
Source File: LogWriter.java From cerebro with GNU Affero General Public License v3.0 | 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 12
Source File: Slf4JLoggerTest.java From netty4.0.27Learn with Apache License 2.0 | 5 votes |
@Test public void testTraceWithException() { Logger mock = createStrictMock(Logger.class); expect(mock.getName()).andReturn("foo"); mock.trace("a", e); replay(mock); InternalLogger logger = new Slf4JLogger(mock); logger.trace("a", e); verify(mock); }
Example 13
Source File: GPUtils.java From GlobalPlatformPro with GNU Lesser General Public License v3.0 | 5 votes |
static void trace_lv(byte[] data, Logger logger) { for (int i = 0; i < data.length; ) { int l= data[i] & 0xFF; logger.trace(String.format("[%02X] %s", l, HexUtils.bin2hex(Arrays.copyOfRange(data, i + 1, i + 1 + l)))); i += 1 + l; } }
Example 14
Source File: MessageLoggers.java From zt-exec with Apache License 2.0 | 4 votes |
public void message(Logger log, String format, Object... arguments) { log.trace(format, arguments); }
Example 15
Source File: ReflexLogNoMessageContext.java From arcusplatform with Apache License 2.0 | 4 votes |
@Override public void run(DeviceDriverContext context, Object value) { Logger log = context.getLogger(); switch (lg.getLevel()) { case TRACE: if (log.isTraceEnabled()) { log.trace(message()); } break; case DEBUG: if (log.isDebugEnabled()) { log.debug(message()); } break; case INFO: if (log.isInfoEnabled()) { log.info(message()); } break; case WARN: if (log.isWarnEnabled()) { log.warn(message()); } break; case ERROR: if (log.isErrorEnabled()) { log.error(message()); } break; default: if (log.isDebugEnabled()) { log.debug(message()); } break; } }
Example 16
Source File: UserException.java From dremio-oss with Apache License 2.0 | 4 votes |
/** * builds a user exception or returns the wrapped one. If the error is a system error, the error message is logged * to the given {@link Logger}. * * @param logger the logger to write to, if null call won't log * @return user exception * @deprecated we are no longer required to log UserExceptions whenever we build them. The user will see the exception * in the query profile, and the caller can always chose to log the exception if really needed. */ @Deprecated public UserException build(final Logger logger) { if (uex != null) { return uex; } boolean isSystemError = errorType == DremioPBError.ErrorType.SYSTEM; // make sure system errors use the root error message and display the root cause class name if (isSystemError) { message = ErrorHelper.getRootMessage(cause); } else if (message == null || message.length() == 0) { // make sure message is not null or empty, otherwise the user will be completely clueless // and it may cause NPE when we generate the corresponding DremioPBError object if (cause != null) { // this case is possible if a user exception wraps a cause with null message (NPE ?) // and we don't set a custom error message message = cause.getClass().getSimpleName(); } else { // we should never hit this unless we are using user exception in the wrong way message = ""; } } final UserException newException = new UserException(this); if (logger != null) { // since we just created a new exception, we should log it for later reference. If this is a // system error, this is // an issue that the system admin should pay attention to and we should log as ERROR. // However, if this is a user // mistake or data read issue, the system admin should not be concerned about these and thus // we'll log this // as an INFO message. try { switch (errorType) { case SYSTEM: logger.error(newException.getMessage(), newException); break; case OUT_OF_MEMORY: logger.error(newException.getMessage(), newException); break; case SCHEMA_CHANGE: case IO_EXCEPTION: logger.debug(newException.getMessage(), newException); break; case VALIDATION: case PLAN: // log SQL validation/plan errors in trace mode since the end user will anyway see // them when failure is reported in UI logger.trace(newException.getMessage(), newException); break; default: logger.info( "User Error Occurred [" + newException.getErrorIdWithIdentity() + "]", newException); } } catch (Throwable ignore) { // logback can cause stack overflow exceptions. // see https://dremio.atlassian.net/browse/DX-15825 Exception e = new Exception("Failure while logging", ignore.getCause()); e.addSuppressed(newException); // we can't log the exception so make sure we are printing to std.out otherwise it will be completely hidden e.printStackTrace(); newException.addSuppressed(ignore); } } return newException; }
Example 17
Source File: EnvUtils.java From arcusplatform with Apache License 2.0 | 4 votes |
public static void devTrace(Logger log, String format, Object arg1, Object arg2) { if (isDevMode()) { log.trace(format, arg1, arg2); } }
Example 18
Source File: EnvUtils.java From arcusplatform with Apache License 2.0 | 4 votes |
public static void devTrace(Logger log, String format, Object arg1) { if (isDevMode()) { log.trace(format, arg1); } }
Example 19
Source File: AsmUtil.java From Bats with Apache License 2.0 | 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()); } }
Example 20
Source File: KLF200Response.java From openhab1-addons with Eclipse Public License 2.0 | 2 votes |
/** * Compare the node identifier of the request with the node identifier within the response * with user-oriented logging in two log levels for monitoring KLF behavior. * * @param logger Instantiated logging class to be used for output. * @param reqNodeID Node identifier of the request. * @param cfmNodeID Node identifier of the response. * @return <b>success</b> of type boolean which signals the success of the communication. */ public static boolean check4matchingNodeID(Logger logger, int reqNodeID, int cfmNodeID) { logger.trace("check4matchingNodeID() called for requestNodeID {} and responseNodeID {}.", reqNodeID, cfmNodeID); return check4matchingAnyID(logger, "NodeID", reqNodeID, cfmNodeID); }