diff --git a/.gitignore b/.gitignore index 1064884..b77b6cc 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,5 @@ build/ ### VS Code ### .vscode/ +log application-prod.properties \ No newline at end of file diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 3e142cd..0a80ba8 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -16,4 +16,5 @@ mybatis.mapper-locations=classpath:mapper/*.xml mybatis.configuration.map-underscore-to-camel-case=true logging.level.root=info -logging.level.top.naccl.dwz=debug \ No newline at end of file +logging.level.top.naccl.dwz=debug +logging.file.name=./log/dwz \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..14b2b55 --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<configuration> + <!--包含Spring boot对logback日志的默认配置--> + <include resource="org/springframework/boot/logging/logback/defaults.xml"/> + <property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}"/> + <include resource="org/springframework/boot/logging/logback/console-appender.xml"/> + + <!--重写了Spring Boot框架 org/springframework/boot/logging/logback/file-appender.xml 配置--> + <appender name="TIME_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <encoder> + <pattern>${FILE_LOG_PATTERN}</pattern> + </encoder> + + <!--<file>${LOG_FILE}.log</file>--> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${LOG_FILE}-%d{yyyy-MM-dd}-%i.log</fileNamePattern> + <maxHistory>365</maxHistory> + <!--Spring Boot默认情况下,日志文件10M时,会切分日志文件--> + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> + <maxFileSize>10MB</maxFileSize> + </timeBasedFileNamingAndTriggeringPolicy> + </rollingPolicy> + </appender> + + <root level="INFO"> + <appender-ref ref="CONSOLE"/> + <appender-ref ref="TIME_FILE"/> + </root> +</configuration> \ No newline at end of file