Skip to content

Commit 220a11a

Browse files
author
YunaiV
committed
增加 log 相关的目录。还未完成
1 parent c7e3f3f commit 220a11a

File tree

31 files changed

+629
-0
lines changed

31 files changed

+629
-0
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.2.2.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>lab-37-logging-actuator</artifactId>
14+
15+
<dependencies>
16+
<!-- 实现对 Spring MVC 的自动化配置 -->
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-web</artifactId>
20+
</dependency>
21+
22+
<!-- 实现对 Actuator 的自动化配置 -->
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-actuator</artifactId>
26+
</dependency>
27+
28+
</dependencies>
29+
30+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cn.iocoder.springboot.lab37.loggingdemo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Application.class, args);
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package cn.iocoder.springboot.lab37.loggingdemo.controller;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
@RestController
10+
@RequestMapping("/demo")
11+
public class DemoController {
12+
13+
private Logger logger = LoggerFactory.getLogger(getClass());
14+
15+
@GetMapping("/debug")
16+
public void debug() {
17+
logger.debug("debug");
18+
}
19+
20+
@GetMapping("/info")
21+
public void info() {
22+
logger.info("info");
23+
}
24+
25+
@GetMapping("/error")
26+
public void error() {
27+
logger.error("error");
28+
}
29+
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
spring:
2+
application:
3+
name: demo-application # 应用名
4+
5+
logging:
6+
# 日志文件配置
7+
file:
8+
# path: /Users/yunai/logs/ # 日志文件路径。
9+
name: /Users/yunai/logs/${spring.application.name}.log # 日志文件名。
10+
max-history: 7 # 日志文件要保留的归档的最大天数。默认为 7 天。
11+
max-size: 10MB # 日志文件的最大大小。默认为 10MB 。
12+
13+
# 日志级别
14+
level:
15+
cn:
16+
iocoder:
17+
springboot:
18+
lab37:
19+
loggingdemo:
20+
controller: DEBUG
21+
22+
management:
23+
endpoints:
24+
# Actuator HTTP 配置项,对应 WebEndpointProperties 配置类
25+
web:
26+
exposure:
27+
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
spring:
2+
application:
3+
name: demo-application # 应用名
4+
5+
logging:
6+
# 日志文件配置
7+
file:
8+
# path: /Users/yunai/logs/ # 日志文件路径。
9+
name: /Users/yunai/logs/${spring.application.name}.log # 日志文件名。
10+
max-history: 7 # 日志文件要保留的归档的最大天数。默认为 7 天。
11+
max-size: 10MB # 日志文件的最大大小。默认为 10MB 。
12+
13+
# 日志级别
14+
level:
15+
cn:
16+
iocoder:
17+
springboot:
18+
lab37:
19+
loggingdemo:
20+
controller: DEBUG
21+
22+
management:
23+
endpoints:
24+
# Actuator HTTP 配置项,对应 WebEndpointProperties 配置类
25+
web:
26+
exposure:
27+
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。

lab-37/lab-37-logging-debug/pom.xml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.2.2.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>lab-37-logging-debug</artifactId>
14+
15+
<dependencies>
16+
<!-- 实现对 Spring MVC 的自动化配置 -->
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-web</artifactId>
20+
</dependency>
21+
</dependencies>
22+
23+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cn.iocoder.springboot.lab37.loggingdemo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Application.class, args);
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package cn.iocoder.springboot.lab37.loggingdemo.controller;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
@RestController
10+
@RequestMapping("/demo")
11+
public class DemoController {
12+
13+
private Logger logger = LoggerFactory.getLogger(getClass());
14+
15+
@GetMapping("/debug")
16+
public void debug() {
17+
logger.debug("debug");
18+
}
19+
20+
@GetMapping("/info")
21+
public void info() {
22+
logger.info("info");
23+
}
24+
25+
@GetMapping("/error")
26+
public void error() {
27+
logger.error("error");
28+
}
29+
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
spring:
2+
application:
3+
name: demo-application # 应用名
4+
5+
logging:
6+
# 日志文件配置
7+
file:
8+
# path: /Users/yunai/logs/ # 日志文件路径。
9+
name: /Users/yunai/logs/${spring.application.name}.log # 日志文件名。
10+
max-history: 7 # 日志文件要保留的归档的最大天数。默认为 7 天。
11+
max-size: 10MB # 日志文件的最大大小。默认为 10MB 。
12+
13+
# 调试模式
14+
debug: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
spring:
2+
application:
3+
name: demo-application # 应用名
4+
5+
logging:
6+
# 日志文件配置
7+
file:
8+
# path: /Users/yunai/logs/ # 日志文件路径。
9+
name: /Users/yunai/logs/${spring.application.name}.log # 日志文件名。
10+
max-history: 7 # 日志文件要保留的归档的最大天数。默认为 7 天。
11+
max-size: 10MB # 日志文件的最大大小。默认为 10MB 。
12+
13+
# 调试模式
14+
debug: true

lab-37/lab-37-logging-demo/pom.xml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.2.2.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>lab-37-logging-demo</artifactId>
14+
15+
<dependencies>
16+
<!-- 实现对 Spring MVC 的自动化配置 -->
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-web</artifactId>
20+
</dependency>
21+
</dependencies>
22+
23+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cn.iocoder.springboot.lab37.loggingdemo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Application.class, args);
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package cn.iocoder.springboot.lab37.loggingdemo.controller;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
@RestController
10+
@RequestMapping("/demo")
11+
public class DemoController {
12+
13+
private Logger logger = LoggerFactory.getLogger(getClass());
14+
15+
@GetMapping("/debug")
16+
public void debug() {
17+
logger.debug("debug");
18+
}
19+
20+
@GetMapping("/info")
21+
public void info() {
22+
logger.info("info");
23+
}
24+
25+
@GetMapping("/error")
26+
public void error() {
27+
logger.error("error");
28+
}
29+
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
spring:
2+
application:
3+
name: demo-application # 应用名
4+
5+
logging:
6+
# 日志文件配置
7+
file:
8+
# path: /Users/yunai/logs/ # 日志文件路径。
9+
name: /Users/yunai/logs/${spring.application.name}.log # 日志文件名。
10+
max-history: 7 # 日志文件要保留的归档的最大天数。默认为 7 天。
11+
max-size: 10MB # 日志文件的最大大小。默认为 10MB 。
12+
13+
# 日志级别
14+
level:
15+
cn:
16+
iocoder:
17+
springboot:
18+
lab37:
19+
loggingdemo:
20+
controller: DEBUG

lab-37/lab-37-logging-log4j2/pom.xml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.2.2.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>lab-37-logging-log4j2</artifactId>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.springframework.boot</groupId>
18+
<artifactId>spring-boot-starter</artifactId>
19+
<exclusions>
20+
<!-- 去掉对 spring-boot-starter-logging 的依赖-->
21+
<exclusion>
22+
<groupId>org.springframework.boot</groupId>
23+
<artifactId>spring-boot-starter-logging</artifactId>
24+
</exclusion>
25+
</exclusions>
26+
</dependency>
27+
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-log4j2</artifactId>
31+
</dependency>
32+
33+
<!-- 实现对 Spring MVC 的自动化配置 -->
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-starter-web</artifactId>
37+
</dependency>
38+
</dependencies>
39+
40+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cn.iocoder.springboot.lab37.loggingdemo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Application.class, args);
11+
}
12+
13+
}

0 commit comments

Comments
 (0)