Java Code Examples for org.slf4j.event.Level#ERROR
The following examples show how to use
org.slf4j.event.Level#ERROR .
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: LinstorParsingUtils.java From linstor-server with GNU General Public License v3.0 | 5 votes |
public static Level asLogLevel(String logLevelRef) { Level logLevel; if (logLevelRef == null || logLevelRef.isEmpty()) { throw new ApiRcException( ApiCallRcImpl.simpleEntry( ApiConsts.FAIL_INVLD_CONF, "Given loglevel is null." ) ); } switch (logLevelRef.toUpperCase()) { case "ERROR": logLevel = Level.ERROR; break; case "WARN": logLevel = Level.WARN; break; case "INFO": logLevel = Level.INFO; break; case "DEBUG": logLevel = Level.DEBUG; break; case "TRACE": logLevel = Level.TRACE; break; default: throw new ApiRcException( ApiCallRcImpl.simpleEntry( ApiConsts.FAIL_INVLD_CONF, "Given loglevel '" + logLevelRef + "' is invalid" ) ); } return logLevel; }
Example 3
Source File: LogAlertTest.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void errorLogAlertTest() { Status exception = new Status(EXCEPTION_MESSAGE); CallbackExceptionAlertHandler callback = new CallbackExceptionAlertHandler(); LogHandler<Status> logExceptionAlertHandler = new LogHandler<Status>(Level.ERROR); CompositeAlertHandler<Status> alertHandler = new CompositeAlertHandler<Status>(Arrays.asList(callback, logExceptionAlertHandler)); CustomStatusAlert exceptionAlert = new CustomStatusAlert(alertHandler); exceptionAlert.alert(exception); assertTrue(callback.called); }
Example 4
Source File: TransformerFactoryBuilderTest.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void errorLogExceptionTest() { TransformerFactoryBuilder secureTransformerBuilder = TransformerFactoryBuilder.getSecureTransformerBuilder(); secureTransformerBuilder.setAttribute("CUSTOM_ATTRIBUTE", "CUSTOM_VALUE"); CallbackExceptionAlertHandler callback = new CallbackExceptionAlertHandler(); LogHandler<Status> logExceptionAlertHandler = new LogHandler<Status>(Level.ERROR); CompositeAlertHandler<Status> alertHandler = new CompositeAlertHandler<Status>(Arrays.asList(callback, logExceptionAlertHandler)); secureTransformerBuilder.setSecurityExceptionAlert(new CustomStatusAlert(alertHandler)); secureTransformerBuilder.build(); assertTrue(callback.called); }
Example 5
Source File: HyenaExceptionHandler.java From hyena with Apache License 2.0 | 5 votes |
private void logException(BaseException exp) { if (exp.getLogLevel() == Level.ERROR) { logger.error(exp.getMessage(), exp); } else if (exp.getLogLevel() == Level.WARN) { logger.warn(exp.getMessage(), exp); } else if (exp.getLogLevel() == Level.INFO) { logger.info(exp.getMessage(), exp); } else if (exp.getLogLevel() == Level.DEBUG) { logger.debug(exp.getMessage(), exp); } else if (exp.getLogLevel() == Level.TRACE) { logger.trace(exp.getMessage(), exp); } else { logger.error(exp.getMessage(), exp); } }
Example 6
Source File: StdErrorReporter.java From linstor-server with GNU General Public License v3.0 | 5 votes |
@Override public Level getCurrentLogLevel() { Level level = null; // no logging, aka OFF org.slf4j.Logger crtLogger = mainLogger; if (crtLogger.isTraceEnabled()) { level = Level.TRACE; } else if (crtLogger.isDebugEnabled()) { level = Level.DEBUG; } else if (crtLogger.isInfoEnabled()) { level = Level.INFO; } else if (crtLogger.isWarnEnabled()) { level = Level.WARN; } else if (crtLogger.isErrorEnabled()) { level = Level.ERROR; } return level; }
Example 7
Source File: LogGobbler.java From liteflow with Apache License 2.0 | 5 votes |
private void log(final String message) { if (this.logger != null) { if(loggingLevel == Level.ERROR) { this.logger.error(message); }else { this.logger.info(message); } } }
Example 8
Source File: MessageContainerBase.java From rqueue with Apache License 2.0 | 5 votes |
void log(Level level, String msg, Throwable t, Object... objects) { if (level == Level.DEBUG && !log.isDebugEnabled()) { return; } if (level == Level.ERROR && !log.isErrorEnabled()) { return; } if (level == Level.INFO && !log.isInfoEnabled()) { return; } if (level == Level.WARN && !log.isWarnEnabled()) { return; } Object[] objects1 = new Object[objects.length + 1 + (t == null ? 0 : 1)]; System.arraycopy(objects, 0, objects1, 1, objects.length); objects1[0] = groupName; if (t != null) { objects1[objects1.length - 1] = t; } String txt = "[{}] " + msg; switch (level) { case INFO: log.info(txt, objects1); break; case WARN: log.warn(txt, objects1); break; case DEBUG: log.debug(txt, objects1); break; case ERROR: log.error(txt, objects1); break; default: log.trace(txt, objects1); } }
Example 9
Source File: HyenaAssert.java From hyena with Apache License 2.0 | 5 votes |
private static <T extends BaseException> BaseException genException(int code, String message, Level logLevel, Class<T> exceptionType) { try { throw exceptionType.getDeclaredConstructor(int.class, String.class, Level.class) .newInstance(code, message, logLevel); } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new HyenaServiceException(message, Level.ERROR); } }
Example 10
Source File: LiteProcess.java From liteflow with Apache License 2.0 | 4 votes |
/** * 运行任务 * @throws IOException */ public void run() throws IOException { if (this.isStarted() || this.isComplete()) { throw new IllegalStateException("this process can only be used once"); } try { final ProcessBuilder builder = new ProcessBuilder(this.cmd); builder.directory(new File(this.workingDir)); builder.environment().putAll(this.env); builder.redirectErrorStream(true); this.process = builder.start(); //获取进程id this.processId = processId(this.process); if (this.processId == 0) { this.logger.info("can not get processId"); } else { this.logger.info("get processId:" + this.processId); } this.startupLatch.countDown(); final LogGobbler outputGobbler = new LogGobbler( new InputStreamReader(this.process.getInputStream(), StandardCharsets.UTF_8), this.logger, Level.INFO, LOG_BUFFER_LINE); final LogGobbler errorGobbler = new LogGobbler( new InputStreamReader(this.process.getErrorStream(), StandardCharsets.UTF_8), this.logger, Level.ERROR, LOG_BUFFER_LINE); LiteThreadPool.getInstance().execute(outputGobbler); LiteThreadPool.getInstance().execute(errorGobbler); int exitCode = -1; try { exitCode = this.process.waitFor(); } catch (final Throwable e) { this.logger.info("process error,exit code is " + exitCode, e); } //进程退出前,搜集日志 outputGobbler.awaitCompletion(WAIT_LOG_COLLECT_TIME); errorGobbler.awaitCompletion(WAIT_LOG_COLLECT_TIME); this.completeLatch.countDown(); /** * 任务运行失败后,通过抛异常来标示 */ if (exitCode != 0) { final String output = new StringBuilder() .append("info:\n") .append(outputGobbler.getRecentLog()) .append("\n\n") .append("error:\n") .append(errorGobbler.getRecentLog()) .append("\n").toString(); throw new ProcessFailureException(exitCode, output); } this.isSuccess = true; } finally { IOUtils.closeQuietly(this.process.getInputStream()); IOUtils.closeQuietly(this.process.getOutputStream()); IOUtils.closeQuietly(this.process.getErrorStream()); if(this.startupLatch.getCount() > 0){ this.startupLatch.countDown(); } if(this.completeLatch.getCount() > 0){ this.completeLatch.countDown(); } } }
Example 11
Source File: MyLogger.java From code-examples with MIT License | 4 votes |
@LogMessage(level=Level.ERROR, message="This is an ERROR message with a very long ID.", id=1548654) void logMessageWithLongId();
Example 12
Source File: BaseException.java From hyena with Apache License 2.0 | 4 votes |
BaseException(int code, String msg, Throwable e) { super(msg, e); this.code = code; logLevel = Level.ERROR; }
Example 13
Source File: BaseException.java From hyena with Apache License 2.0 | 4 votes |
BaseException(int code, String msg) { super(msg); this.code = code; logLevel = Level.ERROR; }
Example 14
Source File: CloudhopperBuilder.java From ogham with Apache License 2.0 | 4 votes |
private ErrorHandler buildReconnectionErrorHandler() { // TODO: make this configurable ? return new LogErrorHandler("Failed to reconnect", Level.ERROR); }
Example 15
Source File: AbstractInterpreterFailureTranslatorLayout.java From panda with Apache License 2.0 | 4 votes |
@Override public Level getLevel() { return Level.ERROR; }
Example 16
Source File: ProcessFailureTranslatorLayout.java From panda with Apache License 2.0 | 4 votes |
@Override public Level getLevel() { return Level.ERROR; }
Example 17
Source File: ExceptionTranslatorLayout.java From panda with Apache License 2.0 | 4 votes |
@Override public Level getLevel() { return Level.ERROR; }