Skip to content

Commit

Permalink
spring boot动态修改日志级别
Browse files Browse the repository at this point in the history
  • Loading branch information
eacdy authored and limu.zl committed Mar 28, 2019
1 parent 3070b17 commit 90ec72d
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<module>spring-boot-banner</module>
<module>spring-boot-mail</module>
<module>spring-boot-lock-redis</module>
<module>spring-boot-logging-change-logging-level</module>
</modules>
</project>
41 changes: 41 additions & 0 deletions spring-boot-logging-change-logging-level/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http:https://maven.apache.org/POM/4.0.0" xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.itmuch</groupId>
<artifactId>spring-boot-logging-change-logging-level</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-logging-change-logging-level</name>
<description>动态修改日志级别</description>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.itmuch.logging;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class LogbackApplication {
public static void main(String[] args) {
SpringApplication.run(LogbackApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.itmuch.logging;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


/**
* @author itmuch.com
*/
@RestController
public class TestController {
private static final Logger LOGGER = LoggerFactory.getLogger(TestController.class);

@GetMapping("/test")
public String simple() {
LOGGER.debug("这是一个debug日志...");
return "test";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
management:
endpoints:
web:
exposure:
include: 'loggers'

0 comments on commit 90ec72d

Please sign in to comment.