当前位置: 首页>>代码示例>>Java>>正文


Java LogLevel类代码示例

本文整理汇总了Java中org.springframework.boot.logging.LogLevel的典型用法代码示例。如果您正苦于以下问题:Java LogLevel类的具体用法?Java LogLevel怎么用?Java LogLevel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LogLevel类属于org.springframework.boot.logging包,在下文中一共展示了LogLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logError

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
public void logError(Exception ex, HttpServletRequest request, LogLevel logLevel) {
    Map<String, String> map = Maps.newHashMap();
    map.put("message", ex.getMessage());
    map.put("from", request.getRemoteAddr());
    final String queryString = request.getQueryString();
    map.put("path", queryString != null ? (request.getRequestURI() + "?" + queryString) : request.getRequestURI());

    switch (logLevel) {
        case ERROR:
            logger.error(JSON.toJSONString(map), ex);
            break;
        case WARN:
            logger.warn(JSON.toJSONString(map));
            break;
    }

}
 
开发者ID:javahongxi,项目名称:whatsmars,代码行数:18,代码来源:AppExceptionHandler.java

示例2: log

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
private void log(org.slf4j.Logger logger, LogLevel level, String message) {
    Objects.requireNonNull(level, "LogLevel must not be null.");
    switch (level) {
        case TRACE:
            logger.trace(message);
            break;
        case DEBUG:
            logger.debug(message);
            break;
        case INFO:
            logger.info(message);
            break;
        case WARN:
            logger.warn(message);
            break;
        case ERROR:
        case FATAL:
            logger.error(message);
            break;
        default:
            break;
    }
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:24,代码来源:Logger.java

示例3: isEnabled

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
private boolean isEnabled(org.slf4j.Logger logger, LogLevel level) {
    Objects.requireNonNull(level, "LogLevel must not be null.");
    switch (level) {
        case TRACE:
            return logger.isTraceEnabled();
        case DEBUG:
            return logger.isDebugEnabled();
        case INFO:
            return logger.isInfoEnabled();
        case WARN:
            return logger.isWarnEnabled();
        case ERROR:
        case FATAL:
            return logger.isErrorEnabled();
        default:
            throw new IllegalArgumentException("LogLevel must be one of the enabled levels.");
    }
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:19,代码来源:Logger.java

示例4: convert

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
private static Level convert(final LogLevel logLevel) {
    switch (logLevel) {
        case FATAL:
            return Level.FATAL;
        case ERROR:
            return Level.ERROR;
        case WARN:
            return Level.WARN;
        case INFO:
            return Level.INFO;
        case DEBUG:
            return Level.DEBUG;
        case TRACE:
            return Level.TRACE;
        case OFF:
            return Level.OFF;
        default:
            return Level.toLevel(logLevel.name());
    }
}
 
开发者ID:apache,项目名称:logging-log4j-boot,代码行数:21,代码来源:Log4jLoggingSystem.java

示例5: post

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
@RequestMapping(
        value = "${edison.application.management.base-path:/internal}/loggers/{name:.*}",
        consumes = {
                ActuatorMediaType.V2_JSON,
                APPLICATION_JSON_VALUE},
        produces = {
                ActuatorMediaType.V2_JSON,
                APPLICATION_JSON_VALUE},
        method = POST)
@ResponseBody
public Object post(@PathVariable String name,
                   @RequestBody Map<String, String> configuration) {
    final String level = configuration.get("configuredLevel");
    final LogLevel logLevel = level == null ? null : LogLevel.valueOf(level.toUpperCase());
    loggersEndpoint.configureLogLevel(name, logLevel);
    return HttpEntity.EMPTY;
}
 
开发者ID:otto-de,项目名称:edison-microservice,代码行数:18,代码来源:LoggersHtmlEndpoint.java

示例6: construct

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
@PostConstruct
protected void construct() {
    warnPoints = new ConcurrentSkipListSet<>();
    warnService = Executors.newSingleThreadScheduledExecutor();
    warnService.scheduleAtFixedRate(() -> {
        for (WarnPoint wp : warnPoints) {
            long duration = System.nanoTime() - wp.getStart();
            if (isOver(duration, wp.getLoggable())) {
                log(LogLevel.WARN, formatter.warnBefore(wp.getPoint(), wp.getLoggable(), duration), wp.getPoint(),
                        wp.getLoggable());
                warnPoints.remove(wp);
            }
        }
    }, 1L, 1L, TimeUnit.SECONDS);
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:16,代码来源:LoggerInterceptor.java

示例7: logMethod

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
public Object logMethod(ProceedingJoinPoint joinPoint, Loggable loggable) throws Throwable {
    long start = System.nanoTime();
    WarnPoint warnPoint = null;
    Object returnVal = null;

    if (isLevelEnabled(joinPoint, loggable) && loggable.warnOver() >= 0) {
        warnPoint = new WarnPoint(joinPoint, loggable, start);
        warnPoints.add(warnPoint);
    }

    if (loggable.entered()) {
        log(loggable.value(), formatter.enter(joinPoint, loggable), joinPoint, loggable);
    }

    try {
        returnVal = joinPoint.proceed();

        long nano = System.nanoTime() - start;
        if (isOver(nano, loggable)) {
            log(LogLevel.WARN, formatter.warnAfter(joinPoint, loggable, returnVal, nano), joinPoint, loggable);
        } else {
            log(loggable.value(), formatter.after(joinPoint, loggable, returnVal, nano), joinPoint, loggable);
        }
        return returnVal;
    } catch (Throwable ex) {
        if (contains(loggable.ignore(), ex)) {
            log(LogLevel.ERROR, formatter.error(joinPoint, loggable, returnVal, System.nanoTime() - start, ex),
                    joinPoint, loggable);
        } else {
            log(formatter.error(joinPoint, loggable, returnVal, System.nanoTime() - start, ex),
                    joinPoint, loggable, ex);
        }
        throw ex;
    } finally {
        if (warnPoint != null) {
            warnPoints.remove(warnPoint);
        }
    }
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:40,代码来源:LoggerInterceptor.java

示例8: log

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
private void log(LogLevel level, String message, ProceedingJoinPoint joinPoint, Loggable loggable) {
    if (loggable.name().isEmpty()) {
        logger.log(level,
                MethodSignature.class.cast(joinPoint.getSignature()).getMethod().getDeclaringClass(), message);
    } else {
        logger.log(level, loggable.name(), message);
    }
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:9,代码来源:LoggerInterceptor.java

示例9: logTrace

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
@Test
public void logTrace() {
    LoggingSystem.get(ClassLoader.getSystemClassLoader())
            .setLogLevel(org.slf4j.Logger.ROOT_LOGGER_NAME, LogLevel.TRACE);
    logger.log(LogLevel.TRACE, "logger name", "trace message");
    assertThat(capture.toString(), containsString("TRACE logger name - trace message"));
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:8,代码来源:LoggerTest.java

示例10: logTraceError

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
@Test
public void logTraceError() {
    LoggingSystem.get(ClassLoader.getSystemClassLoader())
            .setLogLevel(org.slf4j.Logger.ROOT_LOGGER_NAME, LogLevel.TRACE);
    logger.log(LogLevel.TRACE, "logger name", "trace message", new Exception("error message"));
    Pattern pattern = Pattern.compile("TRACE logger name - trace message.*java.lang.Exception: error message",
            Pattern.DOTALL | Pattern.MULTILINE);
    assertTrue(pattern.matcher(capture.toString()).find());
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:10,代码来源:LoggerTest.java

示例11: logDebug

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
@Test
public void logDebug() {
    LoggingSystem.get(ClassLoader.getSystemClassLoader())
            .setLogLevel(org.slf4j.Logger.ROOT_LOGGER_NAME, LogLevel.DEBUG);
    logger.log(LogLevel.DEBUG, "logger name", "debug message");
    assertThat(capture.toString(), containsString("DEBUG logger name - debug message"));
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:8,代码来源:LoggerTest.java

示例12: logDebugError

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
@Test
public void logDebugError() {
    LoggingSystem.get(ClassLoader.getSystemClassLoader())
            .setLogLevel(org.slf4j.Logger.ROOT_LOGGER_NAME, LogLevel.DEBUG);
    logger.log(LogLevel.DEBUG, "logger name", "debug message", new Exception("error message"));
    Pattern pattern = Pattern.compile("DEBUG logger name - debug message.*java.lang.Exception: error message",
            Pattern.DOTALL | Pattern.MULTILINE);
    assertTrue(pattern.matcher(capture.toString()).find());
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:10,代码来源:LoggerTest.java

示例13: logInfo

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
@Test
public void logInfo() {
    LoggingSystem.get(ClassLoader.getSystemClassLoader())
            .setLogLevel(org.slf4j.Logger.ROOT_LOGGER_NAME, LogLevel.INFO);
    logger.log(LogLevel.INFO, "logger name", "info message");
    assertThat(capture.toString(), containsString("INFO logger name - info message"));
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:8,代码来源:LoggerTest.java

示例14: logInfoError

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
@Test
public void logInfoError() {
    LoggingSystem.get(ClassLoader.getSystemClassLoader())
            .setLogLevel(org.slf4j.Logger.ROOT_LOGGER_NAME, LogLevel.INFO);
    logger.log(LogLevel.INFO, "logger name", "info message", new Exception("error message"));
    Pattern pattern = Pattern.compile("INFO logger name - info message.*java.lang.Exception: error message",
            Pattern.DOTALL | Pattern.MULTILINE);
    assertTrue(pattern.matcher(capture.toString()).find());
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:10,代码来源:LoggerTest.java

示例15: logWarning

import org.springframework.boot.logging.LogLevel; //导入依赖的package包/类
@Test
public void logWarning() {
    LoggingSystem.get(ClassLoader.getSystemClassLoader())
            .setLogLevel(org.slf4j.Logger.ROOT_LOGGER_NAME, LogLevel.WARN);
    logger.log(LogLevel.WARN, "logger name", "warn message");
    assertThat(capture.toString(), containsString("WARN logger name - warn message"));
}
 
开发者ID:rozidan,项目名称:logger-spring-boot,代码行数:8,代码来源:LoggerTest.java


注:本文中的org.springframework.boot.logging.LogLevel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。