Search in sources :

Example 1 with AuditlogService

use of com.hazelcast.auditlog.AuditlogService in project hazelcast by hazelcast.

the class LoggingServiceImpl method resetLevel.

/**
 * Resets the levels of all the loggers known to this logging service back
 * to the default reconfigured values. Basically, undoes all the changes done
 * by the previous calls to {@link #setLevel(Level)}, if there were any.
 */
public void resetLevel() {
    if (loggerFactory instanceof InternalLoggerFactory) {
        if (levelSet != null) {
            ((InternalLoggerFactory) loggerFactory).resetLevel();
            levelSet = null;
            AuditlogService auditlogService = node.getNodeExtension().getAuditlogService();
            auditlogService.eventBuilder(AuditlogTypeIds.MEMBER_LOGGING_LEVEL_RESET).message("Log level reset.").log();
        }
    } else {
        throw new HazelcastException("Logger factory doesn't support dynamic log level changes: " + loggerFactory.getClass());
    }
}
Also used : AuditlogService(com.hazelcast.auditlog.AuditlogService) HazelcastException(com.hazelcast.core.HazelcastException)

Example 2 with AuditlogService

use of com.hazelcast.auditlog.AuditlogService in project hazelcast by hazelcast.

the class LoggingServiceImpl method setLevel.

/**
 * Sets the levels of all the loggers known to this logger service to
 * the given level. If a certain logger was already preconfigured with a more
 * verbose level than the given level, it will be kept at that more verbose
 * level.
 * <p>
 * WARNING: Keep in mind that verbose log levels like {@link Level#FINEST}
 * may severely affect the performance.
 *
 * @param level the level to set.
 * @throws HazelcastException if the underlying {@link LoggerFactory} doesn't
 *                            implement {@link InternalLoggerFactory} required
 *                            for dynamic log level changing.
 */
public void setLevel(@Nonnull Level level) {
    if (loggerFactory instanceof InternalLoggerFactory) {
        levelSet = level;
        ((InternalLoggerFactory) loggerFactory).setLevel(level);
        AuditlogService auditlogService = node.getNodeExtension().getAuditlogService();
        auditlogService.eventBuilder(AuditlogTypeIds.MEMBER_LOGGING_LEVEL_SET).message("Log level set.").addParameter("level", level).log();
    } else {
        throw new HazelcastException("Logger factory doesn't support dynamic log level changes: " + loggerFactory.getClass());
    }
}
Also used : AuditlogService(com.hazelcast.auditlog.AuditlogService) HazelcastException(com.hazelcast.core.HazelcastException)

Aggregations

AuditlogService (com.hazelcast.auditlog.AuditlogService)2 HazelcastException (com.hazelcast.core.HazelcastException)2