Java Code Examples for org.jboss.logging.Logger.Level

The following examples show how to use org.jboss.logging.Logger.Level. These examples are extracted from open source projects. 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 Project: keycloak   Source File: TextFileChecker.java    License: 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
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 Project: J2Cache   Source File: J2CacheMessageLogger.java    License: 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 4
Source Project: lams   Source File: SqlExceptionHelper.java    License: 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 5
@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 6
/**
 * 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 7
/**
 * 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 8
/**
 * 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 9
/**
 * 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 10
Source Project: keycloak   Source File: ConfigurationUtil.java    License: 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 11
/**
 * 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
@LogMessage(level = Level.WARN)
@Message(id = 1, value = "Ignoring 'include' child of 'socket-binding-group' %s")
void warnIgnoringSocketBindingGroupInclude(Location location);
 
Example 13
@LogMessage(level = Level.INFO)
@Message(id = 410, value = "Execution of operation '%s' on remote process at address '%s' timed out after %d ms while awaiting final response; remote process has been notified to terminate operation")
void timeoutAwaitingFinalResponse(String operation, PathAddress proxyNodeAddress, long timeout);
 
Example 14
@LogMessage(level = Level.WARN)
@Message(id = 40, value="The slave host controller \"%s\"  could not be reached in the last [%d] milliseconds. Unregistering.")
void slaveHostControllerUnreachable(String hostName, long timeout);
 
Example 15
@LogMessage(level = Level.INFO)
@Message(id = 1703, value = "Ignite instance is stopped. Trying to restart" )
void stoppedIgnite();
 
Example 16
@LogMessage(level = Level.WARN)
@Message( id = 198, value = "Server '%s' is unstable and should be stopped or restarted. An unstable server may not stop normally, " +
        "so the 'kill' operation may be required to terminate the server process.")
void managedServerUnstable(String serverName);
 
Example 17
@LogMessage(level = Level.ERROR)
@Message( id = 195, value = "Failed getting the response from the resume listener for server: %s")
void resumeListenerFailed(@Cause ExecutionException cause, String serverName);
 
Example 18
Source Project: hawkular-agent   Source File: MsgLogger.java    License: Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Level.INFO)
@Message(id = 10000, value = "Starting Hawkular Agent")
void infoStarting();
 
Example 19
@LogMessage(level = Level.INFO)
@Message(id = 188, value = "Timed out after %d ms awaiting server resume response(s) for server: %s")
void timedOutAwaitingResumeResponse(int blockingTimeout, String serverName);
 
Example 20
Source Project: hawkular-agent   Source File: MsgLogger.java    License: Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Level.INFO)
@Message(id = 10003, value = "Hawkular Agent Feed ID = [%s]")
void infoAgentFeedId(String feedId);
 
Example 21
Source Project: hawkular-agent   Source File: MsgLogger.java    License: Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Level.INFO)
@Message(id = 10004, value = "Hawkular Agent is in metrics-only mode")
void infoMetricsOnlyMode();
 
Example 22
@LogMessage(level = Level.ERROR)
@Message(id=142, value = "Failed to apply domain-wide configuration from master host controller")
void failedToApplyDomainConfig(@Cause Exception e);
 
Example 23
Source Project: hawkular-agent   Source File: MsgLogger.java    License: Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Level.WARN)
@Message(id = 10020, value = "The managed server [%s] wants to use an unknown resource type set [%s]")
void warnResourceTypeSetDoesNotExist(String managedServerName, String resourceTypeSetName);
 
Example 24
@LogMessage(level = Level.INFO)
@Message(id = 79, value = "Timed out after %d ms awaiting host prepared response(s) from hosts %s -- cancelling updates for hosts %s")
void timedOutAwaitingHostPreparedResponses(long timeout, Set<String> timeoutHosts, Set<String> allHosts);
 
Example 25
@LogMessage(level = Level.ERROR)
@Message(id = 151, value = "No domain controller discovery configuration was provided and the '%s' attribute was " +
        "set to '%s'. 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 noDomainControllerConfigurationProvidedForAdminOnly(String policyAttribute, AdminOnlyDomainConfigPolicy policy,
                                                         String cachedDcCmdLineArg, RunningMode desiredRunningMode);
 
Example 26
@LogMessage(level = Level.INFO)  // use INFO -- DEBUG is too low as there's a bug here and we want to know;
                                 // WARN is too high as it likely does not harm the end user and the user can't do anything about it
@Message(id = 444, value = "The handler for operation '%s' at address '%s' attempted to add a stage %s step. " +
        "This is not valid for a 'profile' resource on process type %s so this step will not be executed.")
void invalidRuntimeStageForProfile(String operation, String address, OperationContext.Stage stage, ProcessType processType);
 
Example 27
Source Project: hawkular-agent   Source File: MsgLogger.java    License: Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Logger.Level.ERROR)
@Message(id = 10032, value = "Server provided an invalid command request: [%s]")
void errorInvalidCommandRequestFeed(String requestClassName);
 
Example 28
Source Project: hawkular-agent   Source File: MsgLogger.java    License: Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Logger.Level.ERROR)
@Message(id = 10033, value = "Failed to execute command [%s] for server")
void errorCommandExecutionFailureFeed(String requestClassName, @Cause Throwable t);
 
Example 29
Source Project: hawkular-agent   Source File: MsgLogger.java    License: Apache License 2.0 4 votes vote down vote up
@LogMessage(level = Logger.Level.INFO)
@Message(id = 10034, value = "Opened feed WebSocket connection to endpoint [%s]")
void infoOpenedFeedComm(String endpoint);
 
Example 30
@LogMessage(level = Level.INFO)
@Message(id = 184, value = "%s interrupted awaiting server suspend response(s)")
void interruptedAwaitingSuspendResponse(@Cause InterruptedException cause, String serverName);