org.jboss.logging.Logger.Level Java Examples

The following examples show how to use org.jboss.logging.Logger.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: TextFileChecker.java    From keycloak with Apache License 2.0 6 votes vote down vote up
public void checkFiles(boolean verbose, Consumer<Stream<String>> lineChecker) throws IOException {
    for (Path path : paths) {
        log.logf(verbose ? Level.INFO : Level.DEBUG, "Checking server log: '%s'", path.toAbsolutePath());

        if (! Files.exists(path)) {
            continue;
        }

        try (InputStream in = Files.newInputStream(path)) {
            Long lastCheckedPosition = lastCheckedPositions.computeIfAbsent(path, p -> 0L);
            in.skip(lastCheckedPosition);
            BufferedReader b = new BufferedReader(new InputStreamReader(in));
            lineChecker.accept(b.lines());
        }
    }
}
 
Example #2
Source File: CommandContextImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void print(String message, boolean newLine, boolean collect) {
    if (message == null) {
        return;
    }
    final Level logLevel;
    if (exitCode != 0) {
        logLevel = Level.ERROR;
    } else {
        logLevel = Level.INFO;
    }
    if (log.isEnabled(logLevel)) {
        log.log(logLevel, message);
    }

    // Could be a redirection at the aesh command or operation level
    if (invocationContext != null && invocationContext.getConfiguration().getOutputRedirection() != null) {
        OutputDelegate output = invocationContext.getConfiguration().getOutputRedirection();
        output.write(message);
        if (newLine) {
            output.write(Config.getLineSeparator());
        }
        return;
    }

    if (!SILENT) {
        if (console != null) {
            console.print(message, collect);
            if (newLine) {
                console.printNewLine(collect);
            }
        } else { // non-interactive mode
            cliPrintStream.println(message);
        }
    }
}
 
Example #3
Source File: HostControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@LogMessage(level = Level.ERROR)
@Message(id = 144, value = "The host cannot start because it was started in running mode '%s' with no access " +
        "to a local copy of the domain wide configuration policy, the '%s' attribute was set to '%s' and the " +
        "domain wide configuration policy could not be obtained from the Domain Controller host. Startup will be " +
        "aborted. Use the '%s' command line argument to start if you need to start without connecting to " +
        "a domain controller connection.")
void fetchConfigFromDomainMasterFailed(RunningMode currentRunningMode, String policyAttribute,
                                           AdminOnlyDomainConfigPolicy policy,
                                           String cachedDcCmdLineArg);
 
Example #4
Source File: SyslogHandlerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Tests that messages on all levels are logged, when level="TRACE" in syslog handler.
 */
@Test
public void testAllLevelLogs() throws Exception {
    final BlockingQueue<SyslogServerEventIF> queue = BlockedSyslogServerEventHandler.getQueue();
    executeOperation(Operations.createWriteAttributeOperation(SYSLOG_HANDLER_ADDR, "level", "TRACE"));
    queue.clear();
    makeLogs();
    for (Level level : LoggingServiceActivator.LOG_LEVELS) {
        testLog(queue, level);
    }
    Assert.assertTrue("No other message was expected in syslog.", queue.isEmpty());
}
 
Example #5
Source File: SyslogHandlerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Tests if the next message in the syslog is the expected one with the given log-level.
 *
 * @param expectedLevel the expected level of the next log message
 *
 * @throws Exception
 */
private void testLog(final BlockingQueue<SyslogServerEventIF> queue, final Level expectedLevel) throws Exception {
    SyslogServerEventIF log = queue.poll(15L * ADJUSTED_SECOND, TimeUnit.MILLISECONDS);
    assertNotNull(log);
    String msg = log.getMessage();
    assertEquals("Message with unexpected Syslog event level received: " + msg, getSyslogLevel(expectedLevel), log.getLevel());
    final String expectedMsg = LoggingServiceActivator.formatMessage(MSG, expectedLevel);
    assertEquals("Message with unexpected Syslog event text received.", expectedMsg, msg);
}
 
Example #6
Source File: SyslogHandlerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Tests if the next message in the syslog is the expected one with the given log-level.
 *
 * @param expectedLevel the expected level of the next log message
 *
 * @throws Exception
 */
private void testJsonLog(final BlockingQueue<SyslogServerEventIF> queue, final Level expectedLevel) throws Exception {
    final SyslogServerEventIF log = queue.poll(15L * ADJUSTED_SECOND, TimeUnit.MILLISECONDS);
    assertNotNull(log);
    final String msg = log.getMessage();
    assertNotNull(msg);
    try (JsonReader reader = Json.createReader(new StringReader(msg))) {
        final JsonObject json = reader.readObject();
        assertEquals("Message with unexpected Syslog event text received.", expectedLevel.name(), json.getString("level"));
        final String expectedMsg = LoggingServiceActivator.formatMessage(MSG, expectedLevel);
        assertEquals("Message with unexpected Syslog event text received.", expectedMsg, json.getString("message"));
    }
}
 
Example #7
Source File: SyslogHandlerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Convert JBoss Logger.Level to Syslog log level.
 *
 * @param jbossLogLevel
 *
 * @return
 */
private int getSyslogLevel(Level jbossLogLevel) {
    final int result;
    switch (jbossLogLevel) {
        case TRACE:
        case DEBUG:
            result = SyslogConstants.LEVEL_DEBUG;
            break;
        case INFO:
            result = SyslogConstants.LEVEL_INFO;
            break;
        case WARN:
            result = SyslogConstants.LEVEL_WARN;
            break;
        case ERROR:
            result = SyslogConstants.LEVEL_ERROR;
            break;
        case FATAL:
            result = SyslogConstants.LEVEL_EMERGENCY;
            break;
        default:
            // unexpected
            result = SyslogConstants.LEVEL_CRITICAL;
            break;
    }
    return result;
}
 
Example #8
Source File: SqlExceptionHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Log the given (and any nested) exception.
 *
 * @param sqlException The exception to log
 * @param message The message text to use as a preamble.
 */
public void logExceptions(SQLException sqlException, String message) {
	if ( LOG.isEnabled( Level.ERROR ) ) {
		if ( LOG.isDebugEnabled() ) {
			message = StringHelper.isNotEmpty( message ) ? message : DEFAULT_EXCEPTION_MSG;
			LOG.debug( message, sqlException );
		}
		final boolean warnEnabled = LOG.isEnabled( Level.WARN );

		List<String> previousWarnMessages = new ArrayList<>();
		List<String> previousErrorMessages = new ArrayList<>();

		while ( sqlException != null ) {
			if ( warnEnabled ) {
				String warnMessage = "SQL Error: " + sqlException.getErrorCode() + ", SQLState: " + sqlException.getSQLState();
				if ( !previousWarnMessages.contains( warnMessage ) ) {
					LOG.warn( warnMessage );
					previousWarnMessages.add( warnMessage );
				}
			}
			if ( !previousErrorMessages.contains( sqlException.getMessage() ) ) {
				LOG.error( sqlException.getMessage() );
				previousErrorMessages.add( sqlException.getMessage() );
			}
			sqlException = sqlException.getNextException();
		}
	}
}
 
Example #9
Source File: ConfigurationUtil.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public static void logConfigurationState(Configuration c, Logger logger, Level logLevel) {
    Iterator<String> configKeys = c.getKeys();
    while (configKeys.hasNext()) {
        String k = configKeys.next();
        logger.log(logLevel, String.format("Configuration: %s: %s", k, c.getProperty(k)));
    }
}
 
Example #10
Source File: J2CacheMessageLogger.java    From J2Cache with Apache License 2.0 5 votes vote down vote up
/**
 * Logs a message (WARN) about attempt to use an incompatible
 */
@LogMessage(level = Level.WARN)
@Message(
        value = "The default cache value mode for this J2Cache configuration is \"identity\". " +
                "This is incompatible with clustered Hibernate caching - the value mode has therefore been " +
                "switched to \"serialization\"",
        id = 20005
)
void incompatibleCacheValueMode();
 
Example #11
Source File: HostControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Logs an error message indicating this host had no domain controller configuration and cannot start if not in
 * {@link org.jboss.as.controller.RunningMode#ADMIN_ONLY} mode.
 */
@LogMessage(level = Level.ERROR)
@Message(id = 12, value = "No <domain-controller> configuration was provided and the current running mode ('%s') " +
        "requires access to the Domain Controller host. Startup will be aborted. Use the %s command line argument " +
        "to start in %s mode if you need to start without a domain controller connection and then use the management " +
        "tools to configure one.")
void noDomainControllerConfigurationProvided(RunningMode currentRunningMode, String adminOnlyCmdLineArg, RunningMode validRunningMode);
 
Example #12
Source File: HostControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@LogMessage(level = Level.WARN)
@Message(id = 199, value = "Server '%s' (managed by host '%s') has not responded to an operation request within the configured timeout. This may mean the server has become unstable.")
void serverSuspected(String serverName, String hostName);
 
Example #13
Source File: HostControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@LogMessage(level = Level.INFO)
@Message(id = 190, value = "%s interrupted awaiting server resume response(s)")
void interruptedAwaitingResumeResponse(@Cause InterruptedException cause, String serverName);
 
Example #14
Source File: MsgLogger.java    From hawkular-agent with Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Level.INFO)
@Message(id = 10088, value = "Metrics exporter is stopping")
void infoStopMetricsExporter();
 
Example #15
Source File: LoggingActiveMQServerPluginTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
public static void infoLog(Level level, Object message, org.jboss.logging.Logger logger) {

      //only interested in log level INFO
      if (!level.equals(Level.INFO)) {
         return;
      }

      //only interested in one logger
      if (!logger.getName().startsWith(LoggingActiveMQServerPlugin.class.getPackage().getName())) {
         return;
      }

      String stringMessage = (String) message;

      if (stringMessage.startsWith("AMQ841000")) {
         createdConnectionLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841001")) {
         destroyedConnectionLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841002")) {
         createdSessionLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841003")) {
         closedSessionLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841004")) {
         addedSessionMetaData.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841005")) {
         createdConsumerLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841006")) {
         closedConsumerLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841012")) {
         deliveredLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841014")) {
         ackedLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841009")) {
         sentLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841010")) {
         routedLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841007")) {
         createdQueueLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841008")) {
         destroyedQueueLogs.add(stringMessage);
      } else if (stringMessage.startsWith("AMQ841013")) {
         messageExpiredLogs.add(stringMessage);
      } else {
         unexpectedLogs.add(stringMessage);
      }

   }
 
Example #16
Source File: ControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@LogMessage(level = Level.INFO)
@Message(id = 354, value = "Attempting reconnect to syslog handler '%s; after timeout of %d seconds")
void attemptingReconnectToSyslog(String name, int timeout);
 
Example #17
Source File: MsgLogger.java    From hawkular-agent with Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Level.WARN)
@Message(id = 10047, value = "Failed to locate [%s] at location [%s] relative to [%s]")
void warnFailedToLocate(@Cause ProtocolException e, String typeName, String location, String parentLocation);
 
Example #18
Source File: HostControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@LogMessage(level = Level.WARN)
@Message(id = 31, value = "Cannot load the domain model using --backup")
void invalidRemoteBackupPersisterState();
 
Example #19
Source File: ControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@LogMessage(level = Level.ERROR)
@Message(id = 400, value = "Capability '%s' in context '%s' associated with resource '%s' requires capability '%s'. " +
        "It is available in one or more socket binding groups, but not all socket binding capabilities required by " +
        "'%s' can be resolved from a single socket binding group, so this configuration is invalid")
void inconsistentCapabilityContexts(String dependentName, String dependentContext, String address, String requiredName, String dependentContextAgain);
 
Example #20
Source File: ControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@LogMessage(level = Level.WARN)
@Message(id = 405, value = "Couldn't find a transformer to %s, falling back to %s")
void couldNotFindTransformerRegistryFallingBack(ModelVersion currentVersion, ModelVersion fallbackVersion);
 
Example #21
Source File: ControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Logs an error message indicating that a handler failed writing a log message
 */
@LogMessage(level = Level.ERROR)
@Message(id = 37, value = "Update of the management operation audit log failed in handler '%s'")
void logHandlerWriteFailed(@Cause Throwable t, String name);
 
Example #22
Source File: MsgLogger.java    From hawkular-agent with Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Level.INFO)
@Message(id = 10073, value = "Now monitoring the new endpoint [%s]")
void infoAddedEndpointService(String string);
 
Example #23
Source File: MsgLogger.java    From hawkular-agent with Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Level.INFO)
@Message(id = 10068, value = "Agent is already stopped.")
void infoStoppedAlready();
 
Example #24
Source File: MsgLogger.java    From hawkular-agent with Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Level.DEBUG) // making DEBUG as this gets noisy if you run discovery often enough
@Message(id = 10066, value = "Being asked to discover all resources for endpoint [%s]")
void infoDiscoveryRequested(MonitoredEndpoint<?> monitoredEndpoint);
 
Example #25
Source File: MsgLogger.java    From hawkular-agent with Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Level.ERROR)
@Message(id = 10060, value = "Could not close [%s]")
void errorCannotClose(@Cause Throwable t, String name);
 
Example #26
Source File: HostControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@LogMessage(level = Level.WARN)
@Message(id = 203, value = "The domain configuration was successfully applied, but restart is required before changes become active.")
void domainModelAppliedButRestartIsRequired();
 
Example #27
Source File: ControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@LogMessage(level = Level.WARN)
@Message(id = 443, value = "Error getting the password from the supplier %s")
void errorObtainingPassword(@Cause Exception cause, String message);
 
Example #28
Source File: ControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@LogMessage(level = Level.ERROR)
@Message(id = 348, value = "Timeout after [%d] seconds waiting for service container stability. Operation will roll back. Step that first updated the service container was '%s' at address '%s'")
void timeoutExecutingOperation(long blockingTimeout, String name, PathAddress address);
 
Example #29
Source File: MsgLogger.java    From hawkular-agent with Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Level.ERROR)
@Message(id = 10049, value = "Could not access resources of endpoint [%s]")
void errorCouldNotAccess(EndpointService<?, ?> endpoint, @Cause Throwable e);
 
Example #30
Source File: HostControllerLogger.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@LogMessage(level = Level.WARN)
@Message(id = 30, value = "Connection to remote host \"%s\" closed unexpectedly")
void lostConnectionToRemoteHost(String hostId);