diff --git a/whatsmars-spring-boot-samples/pom.xml b/whatsmars-spring-boot-samples/pom.xml index 05999114209f01eed9829aa7a1d5e2b837353b7f..69168525074ae381b064c852d453e0a43570e801 100644 --- a/whatsmars-spring-boot-samples/pom.xml +++ b/whatsmars-spring-boot-samples/pom.xml @@ -30,6 +30,7 @@ whatsmars-boot-sample-datasource whatsmars-boot-sample-thymeleaf whatsmars-boot-sample-swagger + whatsmars-boot-sample-log4j2 diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-datasource/pom.xml b/whatsmars-spring-boot-samples/whatsmars-boot-sample-datasource/pom.xml index 2b8bf6472697dc4cab5d48142b7e2ca58fc1384b..3fc0441829e770be50d2bf3b88d31b0782451caf 100644 --- a/whatsmars-spring-boot-samples/whatsmars-boot-sample-datasource/pom.xml +++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-datasource/pom.xml @@ -15,16 +15,6 @@ org.springframework.boot spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-log4j2 org.springframework.boot diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-datasource/src/main/resources/mybatis-config.xml b/whatsmars-spring-boot-samples/whatsmars-boot-sample-datasource/src/main/resources/mybatis-config.xml index ee9a6f372ef857e0347d48a7679b4ac8368cbd20..a244e07a15908d69f69f60c3068b19b00d8b1360 100644 --- a/whatsmars-spring-boot-samples/whatsmars-boot-sample-datasource/src/main/resources/mybatis-config.xml +++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-datasource/src/main/resources/mybatis-config.xml @@ -4,7 +4,6 @@ "http://mybatis.org/dtd/mybatis-3-config.dtd"> - diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-log4j2/pom.xml b/whatsmars-spring-boot-samples/whatsmars-boot-sample-log4j2/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..a8ae336bb69ccdad9582d286d8feb95a04e3f5a0 --- /dev/null +++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-log4j2/pom.xml @@ -0,0 +1,31 @@ + + + + whatsmars-spring-boot-samples + org.hongxi + Rocket.S9 + + 4.0.0 + + whatsmars-boot-sample-log4j2 + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + + \ No newline at end of file diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-log4j2/src/main/java/org/hongxi/whatsmars/boot/sample/log4j2/SampleLog4j2Application.java b/whatsmars-spring-boot-samples/whatsmars-boot-sample-log4j2/src/main/java/org/hongxi/whatsmars/boot/sample/log4j2/SampleLog4j2Application.java new file mode 100644 index 0000000000000000000000000000000000000000..43e202fd29983e4e06e4a737eda837aca12cc6b3 --- /dev/null +++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-log4j2/src/main/java/org/hongxi/whatsmars/boot/sample/log4j2/SampleLog4j2Application.java @@ -0,0 +1,27 @@ +package org.hongxi.whatsmars.boot.sample.log4j2; + +import javax.annotation.PostConstruct; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SampleLog4j2Application { + + private static final Logger logger = LoggerFactory + .getLogger(SampleLog4j2Application.class); + + @PostConstruct + public void logSomething() { + logger.debug("Sample Debug Message"); + logger.trace("Sample Trace Message"); + } + + public static void main(String[] args) { + SpringApplication.run(SampleLog4j2Application.class, args).close(); + } + +} \ No newline at end of file diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-datasource/src/main/resources/log4j2.xml b/whatsmars-spring-boot-samples/whatsmars-boot-sample-log4j2/src/main/resources/log4j2.xml similarity index 63% rename from whatsmars-spring-boot-samples/whatsmars-boot-sample-datasource/src/main/resources/log4j2.xml rename to whatsmars-spring-boot-samples/whatsmars-boot-sample-log4j2/src/main/resources/log4j2.xml index c281b62b3fc032573ae45982ac958bca6e59076e..416084def6f8f386caf4feddaf31f0b2668e1a38 100644 --- a/whatsmars-spring-boot-samples/whatsmars-boot-sample-datasource/src/main/resources/log4j2.xml +++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-log4j2/src/main/resources/log4j2.xml @@ -2,7 +2,7 @@ - /data/logs/whatsmars-boot-sample-datasource + /tmp/logs/whatsmars-boot-sample-log4j2 @@ -11,7 +11,7 @@ - + - + @@ -36,7 +36,7 @@ - + @@ -50,7 +50,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -79,7 +79,7 @@ - + @@ -87,25 +87,6 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-logback/src/main/resources/application.yml b/whatsmars-spring-boot-samples/whatsmars-boot-sample-logback/src/main/resources/application.yml index 4c64a50a2b4424eb9e0bb52f7fe0662c720cb04d..6242e22333059ac8cec7a70cc952ed3737af2e0f 100644 --- a/whatsmars-spring-boot-samples/whatsmars-boot-sample-logback/src/main/resources/application.yml +++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-logback/src/main/resources/application.yml @@ -1,8 +1,8 @@ logging.level.org.springframework.boot: DEBUG logging: - file: ./logs/whatsmars/whatsmars.log - file-rolling: ./logs/whatsmars/%d{yyyy-MM}/whatsmars.log + file: /tmp/logs/whatsmars/whatsmars.log + file-rolling: /tmp/logs/whatsmars/%d{yyyy-MM}/whatsmars.log max-file-size: 100MB max-history: 365 total-size-cap: 20GB \ No newline at end of file