org.slf4j.event.Level Java Examples

The following examples show how to use org.slf4j.event.Level. 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: StrictPriorityPoller.java    From rqueue with Apache License 2.0 6 votes vote down vote up
@Override
void start() {
  log(Level.DEBUG, "Running, Ordered Queues: {}", null, queues);
  while (true) {
    try {
      String queue = getQueueToPollOrWait();
      if (queue == null) {
        return;
      }
      if (queue.equals(BLANK)) {
        TimeoutUtils.sleepLog(getPollingInterval(), false);
      } else {
        lastFetchedTime.put(queue, System.currentTimeMillis());
        QueueThread queueThread = queueNameToThread.get(queue);
        QueueDetail queueDetail = queueNameToDetail.get(queue);
        poll(-1, queue, queueDetail, queueThread);
      }
    } catch (Exception e) {
      log(Level.ERROR, "Exception in the poller {}", e, e.getMessage());
      if (shouldExit()) {
        return;
      }
    }
  }
}
 
Example #2
Source File: AbstractDSS2058.java    From dss with GNU Lesser General Public License v2.1 6 votes vote down vote up
@BeforeEach
public void init() {
	DSSDocument document = getDocumentToExtend();
	
	CertificateVerifier completeCertificateVerifier = getCompleteCertificateVerifier();
	completeCertificateVerifier.setCheckRevocationForUntrustedChains(true);
	completeCertificateVerifier.setAlertOnMissingRevocationData(new LogOnStatusAlert(Level.WARN));
	completeCertificateVerifier.setAlertOnRevokedCertificate(new LogOnStatusAlert(Level.ERROR));

	PAdESService service = new PAdESService(completeCertificateVerifier);
	service.setTspSource(getCompositeTsa());
	
	PAdESSignatureParameters signatureParameters = new PAdESSignatureParameters();
	signatureParameters.setSignatureLevel(SignatureLevel.PAdES_BASELINE_LTA);
	
	extendedDocument = service.extendDocument(document, signatureParameters);
}
 
Example #3
Source File: Slf4jEventSender.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #4
Source File: BaseModuleIntegTestAbstract.java    From estatio with Apache License 2.0 6 votes vote down vote up
protected BaseModuleIntegTestAbstract(
            final ModuleAbstract module,
            final IntrospectionMode introspectionMode) {

    super(new LogConfig(Level.INFO,
            logPrintStream(Level.DEBUG)),

            new ModuleForTesting(
                    module,
                    new GotenbergRenderingFakeModule(),
                    new FakeCommsServiceModule()
            ).withConfigurationProperty(
                SpecificationLoader.CONFIG_PROPERTY_MODE.of(introspectionMode)
            ).withConfigurationProperty(
                "isis.services.eventbus.implementation", "axon"
            )
    );
}
 
Example #5
Source File: StdErrorReporter.java    From linstor-server with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean setLogLevel(AccessContext accCtx, Level level, Level linstorLevel)
    throws AccessDeniedException
{
    accCtx.getEffectivePrivs().requirePrivileges(Privilege.PRIV_SYS_ALL);
    boolean success = true;
    if (level != null && linstorLevel != null)
    {
        success = setLogLevelImpl(level, linstorLevel);
    }
    else
    if (level != null)
    {
        success = setLogLevelImpl(level, null);
    }
    else
    if (linstorLevel != null)
    {
        success = setLogLevelImpl(null, linstorLevel);
    }
    return success;
}
 
Example #6
Source File: ClientReconnectTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
/**
   * 测试client重连方法不会导致重连线程失效.
   */
  @Test
  public void testClientReconnectMethod() throws RemotingException, InterruptedException{
      int port = NetUtils.getAvailablePort();
      String url = "exchange://127.0.0.3:"+port + "/client.reconnect.test?check=false&"
      +Constants.RECONNECT_KEY+"="+10 //1ms reconnect,保证有足够频率的重连
      +"&reconnect.waring.period=1";
      DubboAppender.doStart();
      Client client = Exchangers.connect(url);
      try {
	client.reconnect();
} catch (Exception e) {
	//do nothing
}
      Thread.sleep(1500);//重连线程的运行
      Assert.assertTrue("have more then one warn msgs . bug was :" + LogUtil.findMessage(Level.WARN, "client reconnect to "),LogUtil.findMessage(Level.WARN, "client reconnect to ") >1);
      DubboAppender.doStop();
  }
 
Example #7
Source File: LogConfigurator.java    From butterfly with MIT License 5 votes vote down vote up
public void setDebugMode(boolean on) {
    if(on) {
        setLoggerLevel("com.paypal.butterfly", Level.DEBUG);
    } else {
        setLoggerLevel("com.paypal.butterfly", Level.INFO);
    }
}
 
Example #8
Source File: WorkerPoolTest.java    From linstor-server with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String reportProblem(
    Level logLevel,
    LinStorException errorInfo,
    AccessContext accCtx,
    Peer client,
    String contextInfo
)
{
    unexpected.add(errorInfo);
    return null; // no error report, no logName
}
 
Example #9
Source File: LambdaLoggerPlainImplTest.java    From slf4j-lambda with Apache License 2.0 5 votes vote down vote up
@Test
public void doLog_format_arguments_enabled_args_null() throws Exception {
    when(underlyingLogger.isWarnEnabled(testMarker)).thenReturn(true);

    lambdaLogger.doLog(testMarker, Level.WARN, "message format", null, testException);

    verify(underlyingLogger, times(1)).warn(eq(testMarker), eq("message format"), eq(testException));
}
 
Example #10
Source File: GlobalDefaultExceptionHandler.java    From apollo with Apache License 2.0 5 votes vote down vote up
private ResponseEntity<Map<String, Object>> handleError(HttpServletRequest request,
                                                        HttpStatus status, Throwable ex, Level logLevel) {
  String message = ex.getMessage();
  printLog(message, ex, logLevel);

  Map<String, Object> errorAttributes = new HashMap<>();
  boolean errorHandled = false;

  if (ex instanceof HttpStatusCodeException) {
    try {
      //try to extract the original error info if it is thrown from apollo programs, e.g. admin service
      errorAttributes = gson.fromJson(((HttpStatusCodeException) ex).getResponseBodyAsString(), mapType);
      status = ((HttpStatusCodeException) ex).getStatusCode();
      errorHandled = true;
    } catch (Throwable th) {
      //ignore
    }
  }

  if (!errorHandled) {
    errorAttributes.put("status", status.value());
    errorAttributes.put("message", message);
    errorAttributes.put("timestamp",
        LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
    errorAttributes.put("exception", ex.getClass().getName());

  }

  HttpHeaders headers = new HttpHeaders();
  headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
  return new ResponseEntity<>(errorAttributes, headers, status);
}
 
Example #11
Source File: DolphinLoggerConfiguration.java    From dolphin-platform with Apache License 2.0 5 votes vote down vote up
public Level getLevelFor(final String loggerName) {
    return loggerLevelMap.keySet().stream().
            filter(v -> loggerName.startsWith(v)).
            sorted((a, b) -> a.compareTo(b)).
            findFirst().
            map(v -> loggerLevelMap.get(v)).
            orElse(getGlobalLevel());
}
 
Example #12
Source File: LambdaLoggerTest.java    From slf4j-lambda with Apache License 2.0 5 votes vote down vote up
@Test
public void trace_marker_format_argSupplier1() throws Exception {
    lambdaLogger.trace(testMarker, "trace format", () -> "arg1");

    verify(lambdaLogger).doLog(eq(testMarker), eq(Level.TRACE), eq("trace format"), argSuppliersCaptor.capture(), eq(null));

    Supplier[] suppliers = argSuppliersCaptor.getValue();
    assertThat(suppliers.length).isEqualTo(1);
    assertThat(suppliers[0].get()).isEqualTo("arg1");
}
 
Example #13
Source File: StdErrorReporter.java    From linstor-server with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String reportError(
    Level logLevel,
    Throwable errorInfo,
    AccessContext accCtx,
    Peer client,
    String contextInfo
)
{
    return reportErrorImpl(logLevel, errorInfo, accCtx, client, contextInfo);
}
 
Example #14
Source File: DBLogReader.java    From background-geolocation-android with Apache License 2.0 5 votes vote down vote up
private Collection<LogEntry> getDbEntries(int limit, int fromLogEntryId, Level minLevel) throws SQLException {
    Collection<LogEntry> entries = new ArrayList<LogEntry>();
    SQLiteDatabase db = openDatabase();
    Cursor cursor = null;

    try {
        DefaultDBNameResolver dbNameResolver = getDbNameResolver();
        QueryBuilder qb = new QueryBuilder(dbNameResolver);
        cursor = db.rawQuery(qb.buildQuery(limit, fromLogEntryId, minLevel), new String[] {});
        while (cursor.moveToNext()) {
            LogEntry entry = new LogEntry();
            entry.setContext(0);
            entry.setId(cursor.getInt(cursor.getColumnIndex(mDbNameResolver.getColumnName(ColumnName.EVENT_ID))));
            entry.setLevel(cursor.getString(cursor.getColumnIndex(dbNameResolver.getColumnName(ColumnName.LEVEL_STRING))));
            entry.setMessage(cursor.getString(cursor.getColumnIndex(dbNameResolver.getColumnName(ColumnName.FORMATTED_MESSAGE))));
            entry.setTimestamp(cursor.getLong(cursor.getColumnIndex(dbNameResolver.getColumnName(ColumnName.TIMESTMP))));
            entry.setLoggerName(cursor.getString(cursor.getColumnIndex(dbNameResolver.getColumnName(ColumnName.LOGGER_NAME))));
            if ("ERROR".equals(entry.getLevel())) {
                entry.setStackTrace(getStackTrace(entry.getId()));
            }
            entries.add(entry);
        }
    } catch (SQLiteException e) {
        throw new SQLException("Cannot retrieve log entries", e);
    } finally {
        if (cursor != null) {
            cursor.close();
        }
        if (db != null) {
            db.close();
        }
    }

    return entries;
}
 
Example #15
Source File: Server.java    From sftpserver with Apache License 2.0 5 votes vote down vote up
public boolean checkUserPassword(final ServerSession session, final String user, final String pwd) {
	final StringBuilder sb = new StringBuilder(40);
	boolean traceInfo = false;
	boolean authOk = false;
	try {
		if (!isEnabledUser(user)) {
			sb.append("[user disabled]");
			return authOk;
		}
		final String value = getValue(user, PROP_PWD);
		if (value == null) {
			sb.append("[no password]");
			return authOk;
		}
		final boolean isCrypted = PasswordEncrypt.isCrypted(value);
		authOk = isCrypted ? PasswordEncrypt.checkPassword(value, pwd) : value.equals(pwd);
		if (!isCrypted) {
			sb.append("[config-unencrypted]");
		}
		traceInfo = isCrypted;
	} finally {
		sb.append("[").append(authOk ? "OK" : "FAIL").append("]");
		if (authOk) {
			logger.authPasswordPostLogin(session, user, (traceInfo ? Level.INFO : Level.WARN), sb.toString());
		} else {
			logger.authPasswordPostLogin(session, user, Level.ERROR, sb.toString());
		}
	}
	return authOk;
}
 
Example #16
Source File: BasicJsonTests.java    From structlog4j with MIT License 5 votes vote down vote up
@Test
public void singleKeyNullValueTest() {
    log.error("This is an error","user",null);

    assertEquals(entries.toString(),1,entries.size());
    JsonTestUtils.assertJsonMessage(entries,0);
    assertMessage(entries,0,Level.ERROR,"{\"message\":\"This is an error\",\"user\":null}",false);
}
 
Example #17
Source File: LambdaLoggerTest.java    From slf4j-lambda with Apache License 2.0 5 votes vote down vote up
@Test
public void info_msgSupplier_throwable() throws Exception {
    lambdaLogger.info(() -> "info message sup", testException);

    verify(lambdaLogger).doLog(eq(null), eq(Level.INFO), msgSupplierCaptor.capture(), eq(testException));

    assertThat(msgSupplierCaptor.getValue().get()).isEqualTo("info message sup");
}
 
Example #18
Source File: MessageContainerBase.java    From rqueue with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
  try {
    start();
  } catch (Exception e) {
    log(Level.ERROR, "Failed {}", e, e.getMessage());
  }
}
 
Example #19
Source File: StrictPriorityPoller.java    From rqueue with Apache License 2.0 5 votes vote down vote up
private String getQueueToPollOrWait() {
  String queueToPoll = getQueueToPoll();
  if (queueToPoll == null) {
    if (shouldExit()) {
      return null;
    }
    queueToPoll = "";
  }
  log(Level.DEBUG, "Queue to be poll : {}", null, queueToPoll);
  return queueToPoll;
}
 
Example #20
Source File: TimedSQLFileWriter.java    From dkpro-jwpl with Apache License 2.0 5 votes vote down vote up
/**
 * This method will process the given DiffTask and send him to the specified
 * output.
 *
 * @param task
 *            DiffTask
 *
 * @throws ConfigurationException
 *             if problems occurred while initializing the components
 *
 * @throws IOException
 *             if problems occurred while writing the output (to file or
 *             archive)
 *
 * @throws SQLConsumerException
 *             if problems occurred while writing the output (to the sql
 *             producer database)
 */
@Override
public void process(final Task<Diff> task)
	throws ConfigurationException, IOException, SQLConsumerException
{

	long startTime = System.currentTimeMillis();

	TaskTypes type = task.getTaskType();

	if (type == TaskTypes.TASK_FULL || type == TaskTypes.TASK_PARTIAL_FIRST) {

		this.sqlEncoder.init();
		this.processingTimeSQL = 0;
	}

	super.process(task);

	this.processingTimeSQL += System.currentTimeMillis() - startTime;

	if (type == TaskTypes.TASK_FULL || type == TaskTypes.TASK_PARTIAL_LAST) {

		ArticleInformation info = task.getHeader();
		info.setEncodedSize(this.sqlEncoder.getEncodedSize());
		info.setEncodedSQLSize(this.sqlEncoder.getEncodedSQLSize());
		info.setExitingTime(System.currentTimeMillis());
		info.setProcessingTimeSQL(processingTimeSQL);

		String succesReport = info.toString();
		// System.out.println(succesReport);
		this.outputLogger.logMessage(Level.INFO, "\r\n" + succesReport);
	}
}
 
Example #21
Source File: DiffConsumerLogMessages.java    From dkpro-jwpl with Apache License 2.0 5 votes vote down vote up
/**
 * Logs the occurance of an TaskOutOfMemoryError while reading a revision
 * task.
 *
 * @param logger
 *            reference to the logger
 * @param task
 *            reference to the revision task
 * @param e
 *            reference to the error
 */
public static void logReadTaskOutOfMemoryError(final Logger logger,
		final Task<Revision> task, final OutOfMemoryError e)
{

	if (task != null) {
		logger.logError(Level.WARN, "Error while reading a task: "
				+ task.toString(), e);
	}
	else {
		logger.logError(Level.WARN,
				"Error while reading an unknown task", e);
	}
}
 
Example #22
Source File: BasicJsonTests.java    From structlog4j with MIT License 5 votes vote down vote up
@Test
public void iToLogSingleTest() {
    log.error("This is an error",iToLog);

    assertEquals(entries.toString(),1,entries.size());
    JsonTestUtils.assertJsonMessage(entries,0);
    assertMessage(entries,0,Level.ERROR,"{\"message\":\"This is an error\",\"userName\":\"Test User\",\"tenantId\":\"TEST_TENANT\"}", false);
}
 
Example #23
Source File: LoggingInterceptor.java    From google-ads-java with Apache License 2.0 5 votes vote down vote up
/**
 * Logs an RPC call detailed message containing full request/response + headers. The level chosen
 * will depend on the response status (OK=DEBUG, FAILURE=INFO). Also checks if the logger is
 * enabled for the RPC status and logger configuration before computing message params.
 */
private void logDetail(
    Status responseStatus,
    MethodDescriptor method,
    ImmutableMap<String, String> requestHeaders,
    String endpoint,
    Object request,
    Metadata responseHeaders,
    Metadata responseTrailers,
    Object response) {
  Level level = getDetailLevel(responseStatus);
  if (requestLogger.isDetailEnabled(level)) {
    String methodName = getMethodName(method);
    boolean isSuccess = isSuccess(responseStatus);
    Event.Detail event =
        Event.Detail.builder()
            .setResponseStatus(responseStatus)
            .setSuccess(isSuccess)
            .setMethodName(methodName)
            .setRawRequestHeaders(requestHeaders)
            .setScrubbedRequestHeaders(scrubbedRequestHeaders)
            .setEndpoint(endpoint)
            .setRequest(request)
            .setResponseHeaderMetadata(responseHeaders)
            .setResponseTrailerMetadata(responseTrailers)
            .setResponse(response)
            .build();
    requestLogger.logDetail(level, event);
  }
}
 
Example #24
Source File: TransformationTemplateTest.java    From butterfly with MIT License 5 votes vote down vote up
@Test
public void debugTest2() {
    TransformationTemplate transformationTemplate = getNewTestTransformationTemplate();
    assertEquals(transformationTemplate.getUtilities().size(), 0);
    transformationTemplate.debug("test {}", "ATT");
    assertEquals(transformationTemplate.getUtilities().size(), 1);
    Log log = (Log) transformationTemplate.getUtilities().get(0);

    assertEquals(log.getLogLevel(), Level.DEBUG);
    assertEquals(log.getLogMessage(), "test {}");
    assertEquals(log.getAttributeNames(), new String[]{"ATT"});
}
 
Example #25
Source File: LambdaLoggerUtils.java    From slf4j-lambda with Apache License 2.0 5 votes vote down vote up
/**
 * check if log level is enabled in the underlying logger
 *
 * @param underlyingLogger real Slf4j Logger implementation
 * @param logLevel log level
 * @param marker marker
 * @return true if log level is enabled or false.
 */
public static boolean isLogLevelEnabled(Logger underlyingLogger, Level logLevel, Marker marker) {
    switch (logLevel) {
        case TRACE:
            if (marker == null) {
                return underlyingLogger.isTraceEnabled();
            }
            return underlyingLogger.isTraceEnabled(marker);
        case DEBUG:
            if (marker == null) {
                return underlyingLogger.isDebugEnabled();
            }
            return underlyingLogger.isDebugEnabled(marker);
        case INFO:
            if (marker == null) {
                return underlyingLogger.isInfoEnabled();
            }
            return underlyingLogger.isInfoEnabled(marker);
        case WARN:
            if (marker == null) {
                return underlyingLogger.isWarnEnabled();
            }
            return underlyingLogger.isWarnEnabled(marker);
        case ERROR:
            if (marker == null) {
                return underlyingLogger.isErrorEnabled();
            }
            return underlyingLogger.isErrorEnabled(marker);
        default:
            break;
    }
    return false;
}
 
Example #26
Source File: StderrErrorReporter.java    From linstor-server with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean hasAtLeastLogLevel(Level leveRef)
{
    return true;
}
 
Example #27
Source File: EmptyErrorReporter.java    From linstor-server with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Level getCurrentLogLevel()
{
    return Level.TRACE;
}
 
Example #28
Source File: LambdaLogger.java    From slf4j-lambda with Apache License 2.0 4 votes vote down vote up
/**
 * {@link #warn(org.slf4j.Marker, java.lang.String, java.lang.Object, java.lang.Object)} with two lambda argument suppliers.
 */
default void warn(Marker marker, String format, Supplier<?> argSupplier1, Supplier<?> argSupplier2) {
    doLog(marker, Level.WARN, format, new Supplier<?>[]{argSupplier1, argSupplier2}, null);
}
 
Example #29
Source File: LambdaLogger.java    From slf4j-lambda with Apache License 2.0 4 votes vote down vote up
/**
 * {@link #info(java.lang.String, java.lang.Object...)} with 3 or more lambda argument suppliers.
 */
default void info(String format, Supplier<?>... argSuppliers) {
    doLog(null, Level.INFO, format, argSuppliers, null);
}
 
Example #30
Source File: DolphinLogger.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void trace(final String message, final Object arg) {
    log(Level.TRACE, null, message, null, arg);
}