List of utility methods to do slf4j Logger
int | parsePortNumber(String port, int defaultPort) parse Port Number int proxyPort = defaultPort; if (port != null) { try { proxyPort = Integer.parseInt(port); } catch (NumberFormatException ne) { LOGGER.warn("Unable to parse port '" + port + "'. Using default port number " + defaultPort, ne); return proxyPort; |
void | printInfoLog(Class> cla, String message) print Info Log LoggerFactory.getLogger(cla).info(message); |
void | printPrettyJson(Logger logger, String json) print Pretty Json try { ObjectMapper mapper = new ObjectMapper(); logger.info(mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(mapper.readValue(json, Object.class))); } catch (Exception e) { e.printStackTrace(); |
void | printRequestLog(Map print Request Log writeMessage(LOG_STRING_REQ_MSG_BEGIN); Iterator<Entry<String, String>> it = reqParam.entrySet().iterator(); while (it.hasNext()) { Entry<String, String> en = it.next(); writeMessage("[" + en.getKey() + "] = [" + en.getValue() + "]"); writeMessage(LOG_STRING_REQ_MSG_END); |
void | printResponseLog(String res) print Response Log writeMessage(LOG_STRING_RSP_MSG_BEGIN); writeMessage(res); writeMessage(LOG_STRING_RSP_MSG_END); |
void | printStackTrace(Logger logger, Throwable e) print Stack Trace String stackStr = ""; StackTraceElement[] stacks = e.getStackTrace(); logger.error(e.getMessage()); for (int i = 0; i < stacks.length; i++) { stackStr = "File " + stacks[i].getFileName() + " Class " + stacks[i].getClassName() + " Method " + stacks[i].getMethodName() + " Line " + stacks[i].getLineNumber(); logger.error(stackStr); |
void | profilerTrigger2(Logger log, String msg) profiler Trigger log.info("profilerTrigger2(); called");
|
void | putMDCs(String clientId, String subjectId) put MD Cs MDC.put(CLIENT_ID, clientId); MDC.put(SUBJECT_ID, subjectId); |
void | request(String infoMessage) request request.info(infoMessage); |
void | restoreContext(Map restore Context if (mdcContextMap == null || mdcContextMap.isEmpty()) { MDC.clear(); } else { MDC.setContextMap(mdcContextMap); |