Spring boot 2.0 + Configure log4j logs

1. Maven introduces the package and excludes the default log

 1 

2 org.springframework.boot
3 spring-boot-starter
4
5
6 org.springframework.boot
7 spring-boot-starter-logging
8

9

10

11
12 org.springframework.boot
13 spring-boot-starter-log4j2
14

2, add a configuration file, put it under resources, start the project, The log can be recorded, and the modification of the related configuration can be operated in the configuration file.

share picture

 1 xml version="1.0" encoding="UTF-8"?>

2 < configuration>
3 < appenders>
4
5 < console name="Console" target="SYSTEM_OUT">
6 < PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class %L %M-%msg%n"/>
7 console>
8
9
10 < RollingFile name="all" fileName="logs/allOut.log"
11 filePattern ="logs/$${date:yyyy-MM-dd}/allOut-%d{yyyy-MM-dd}-%i.log">
12 < Filters>
13 < ThresholdFilter level="all" onMatch="ACCEPT" onMismatch="DENY"/>
14 Filters>
15
16 < PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M-%msg%n"/>
17 < Policies>
18
19 < SizeBasedTriggeringPolicy size="2 MB"/>
20 Policies>
21
22 < DefaultRolloverStrategy max="50"/>
23 RollingFile>
24
25 < RollingFile name="err" fileName="logs/err.log"
26 filePattern ="logs/$${date:yyyy-MM-dd}/err-%d{yyyy-MM-dd}-%i.log">
27 < Filters>
28 < ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
29 Filters>
30
31 < PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M-%msg%xEx%n"/>
32 < Policies>
33
34 < SizeBasedTriggeringPolicy size="10MB"/>
35 Policies>
36
37 < DefaultRolloverStrategy max="50"/>
38 RollingFile>
39 appenders>
40
41 < loggers>
42
43 < logger name="org.springframework" level="error"> logger>
44
45 < root level="debug">
46 < appender-ref ref="Console"/>
47 < appender-ref ref="all"/>
48 < appender-ref ref="err"/>
49 root>
50 loggers>
51
52 configuration>

Configuration file

< /p>

 1 

2 org.springframework.boot
3 spring-boot-starter
4
5
6 org.springframework.boot
7 spring-boot-starter-logging
8

9

10

11
12 org.springframework.boot
13 spring-boot-starter-log4j2
14

share picture

 1 < span style="color: #0000ff;">xml version="1.0" encoding="UTF-8"?>

2 < configuration>
3 < appenders>
4
5 < console name="Console" target="SYSTEM_OUT">
6 < PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class %L %M-%msg%n"/>
7 console>
8
9
10 < RollingFile name="all" fileName="logs/allOut.log"
11 filePattern ="logs/$${date:yyyy-MM-dd}/allOut-%d{yyyy-MM-dd}-%i.log">
12 < Filters>
13 < ThresholdFilter level="all" onMatch="ACCEPT" onMismatch="DENY"/>
14 Filters>
15
16 < PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M-%msg%n"/>
17 < Policies>
18
19 < SizeBasedTriggeringPolicy size="2 MB"/>
20 Policies>
21
22 < DefaultRolloverStrategy max="50"/>
23 RollingFile>
24
25 < RollingFile name="err" fileName="logs/err.log"
26 filePattern ="logs/$${date:yyyy-MM-dd}/err-%d{yyyy-MM-dd}-%i.log">
27 < Filters>
28 < ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
29 Filters>
30
31 < PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M-%msg%xEx%n"/>
32 < Policies>
33
34 < SizeBasedTriggeringPolicy size="10MB"/>
35 Policies>
36
37 < DefaultRolloverStrategy max="50"/>
38 RollingFile>
39 appenders>
40
41 < loggers>
42
43 < logger name="org.springframework" level="error"> logger>
44
45 < root level="debug">
46 < appender-ref ref="Console"/>
47 < appender-ref ref="all"/>
48 < appender-ref ref="err"/>
49 root>
50 loggers>
51
52 configuration>

Configuration file

< p>

 1 xml version="1.0" encoding="UTF-8"?>

2 < configuration>
3 < appenders>
4
5 < console name="Console" target="SYSTEM_OUT">
6 < PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class %L %M-%msg%n"/>
7 console>
8
9
10 < RollingFile name="all" fileName="logs/allOut.log"
11 filePattern ="logs/$${date:yyyy-MM-dd}/allOut-%d{yyyy-MM-dd}-%i.log">
12 < Filters>
13 < ThresholdFilter level="all" onMatch="ACCEPT" onMismatch="DENY"/>
14 Filters>
15
16 < PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M-%msg%n"/>
17 <Policies>
18
19 <SizeBasedTriggeringPolicy size="2 MB"/>
20 Policies>
21
22 <DefaultRolloverStrategy max="50"/>
23 RollingFile>
24
25 <RollingFile name="err" fileName="logs/err.log"
26 filePattern="logs/$${date:yyyy-MM-dd}/err-%d{yyyy-MM-dd}-%i.log">
27 <Filters>
28 <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
29 Filters>
30
31 <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
32 <Policies>
33
34 <SizeBasedTriggeringPolicy size="10MB"/>
35 Policies>
36
37 <DefaultRolloverStrategy max="50"/>
38 RollingFile>
39 appenders>
40
41 <loggers>
42
43 <logger name="org.springframework" level="error">logger>
44
45 <root level="debug">
46 <appender-ref ref="Console"/>
47 <appender-ref ref="all"/>
48 <appender-ref ref="err"/>
49 root>
50 loggers>
51
52 configuration>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4686 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.