SpringBoot 동적 수정 로그 수준

4417 단어
SpringBoot1.5 새로운 기능
카탈로그
4
  • 설치 종속 4
  • 4
  • 테스트 로그 레벨 4
  • 4
  • 테스트 수정 로그 레벨 4
  • 1.pom에 의존 추가
    
    <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>1.5.1.RELEASEversion>
        <relativePath/> 
    parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-actuatorartifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>
    dependencies>

    2. 테스트 시작
    http://localhost:8080/loggers
    서비스:
    s.b.a.e.m.MvcEndpointSecurityInterceptor : Full authentication is required to access actuator endpoints. Consider adding Spring Security or set 'management.security.enabled' to false.
    

    매니지먼트를 수동으로 설정해야 합니다.security.enabled=false
    - 테스트 계속
    http://localhost:8080/loggers
    서비스 반환:
    {
    levels: [
    "OFF",
    "ERROR",
    "WARN",
    "INFO",
    "DEBUG",
    "TRACE"
    ],
    loggers: {
    ROOT: {
    configuredLevel: "INFO",
    effectiveLevel: "INFO"
    },
    elephant: {
    configuredLevel: "DEBUG",
    effectiveLevel: "DEBUG"
    },
    ...
    

    3. 로그 레벨 수정
    POST 요청http://localhost:8080/loggers/{elephant}
    {}/loggers 방법에 따라 되돌아오는 디렉터리 레벨 추가
    eg:
    elephant를 수정하려고 합니다.zybank.rest 디렉토리 하위 수준
    다음 요청 방법을 사용하겠습니다.
    http://localhost:8080/loggers/elephant.zybank.rest
    요청체에서 json 사용하기
    {
        "configuredLevel": "DEBUG"
    }

    로그인 서버
    curl -H "Content-Type: application/json" -X POST --data 
    '
    {
        "configuredLevel": "DEBUG"
    }
    ' 
    http://localhost:8080/loggers/elephant.zybank.rest

    좋은 웹페이지 즐겨찾기