fix:修改日志

上级 73cca3e4
package com.kwan.springbootkwan.config; package com.kwan.springbootkwan.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
...@@ -13,21 +14,22 @@ import javax.servlet.http.HttpServletResponse; ...@@ -13,21 +14,22 @@ import javax.servlet.http.HttpServletResponse;
* @version : 2.2.0 * @version : 2.2.0
* @date : 2022/12/19 16:14 * @date : 2022/12/19 16:14
*/ */
@Slf4j
public class MyInterceptor implements HandlerInterceptor { public class MyInterceptor implements HandlerInterceptor {
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
System.out.println("MyInterceptor>>>>>>>>>preHandle"); log.info("MyInterceptor>>>>>>>>>preHandle");
return true; return true;
} }
@Override @Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
System.out.println("MyInterceptor>>>>>>>>>postHandle"); log.info("MyInterceptor>>>>>>>>>postHandle");
} }
@Override @Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
System.out.println("MyInterceptor>>>>>>>>>afterCompletion"); log.info("MyInterceptor>>>>>>>>>afterCompletion");
} }
} }
...@@ -3,6 +3,7 @@ package com.kwan.springbootkwan.config; ...@@ -3,6 +3,7 @@ package com.kwan.springbootkwan.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
...@@ -10,13 +11,14 @@ import org.springframework.data.redis.core.RedisTemplate; ...@@ -10,13 +11,14 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer;
@Slf4j
@Configuration @Configuration
public class RedisConfig { public class RedisConfig {
@Bean @Bean
@SuppressWarnings("all") @SuppressWarnings("all")
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) { public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
System.out.println("==================自定义的redisTemplate实例化了==================="); log.info("==================自定义的redisTemplate实例化了===================");
RedisTemplate<String, Object> template = new RedisTemplate<String, Object>(); RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
template.setConnectionFactory(factory); template.setConnectionFactory(factory);
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
......
package com.kwan.springbootkwan.entity; package com.kwan.springbootkwan.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date; import java.util.Date;
@Data
@TableName(value = "ads_dim_financial_year_week_info")
@ApiModel(value = "财年周") @ApiModel(value = "财年周")
public class AdsDimFinancialYearWeekInfo extends Model<AdsDimFinancialYearWeekInfo> { public class AdsDimFinancialYearWeekInfo extends Model<AdsDimFinancialYearWeekInfo> {
//财年 @TableId
@ApiModelProperty(value = "财年")
private Integer financialYear; private Integer financialYear;
//第n财年周 @ApiModelProperty(value = "第n财年周")
private Integer financialYearWeek; private Integer financialYearWeek;
//财年开始日期 @ApiModelProperty(value = "财年开始日期")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date financialYearStart; private Date financialYearStart;
//财年结束日期
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "财年结束日期")
private Date financialYearEnd; private Date financialYearEnd;
//周开始
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "周开始")
private Date weekStartDay; private Date weekStartDay;
//周结束
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "周结束")
private Date weekEndDay; private Date weekEndDay;
//财年周所在季节区间,0:跨9月1号,1:3月到8月,2:9月到2月 @ApiModelProperty(value = "财年周所在季节区间,0:跨9月1号,1:3月到8月,2:9月到2月 ")
private Integer weekInSeason; private Integer weekInSeason;
}
\ No newline at end of file
public Integer getFinancialYear() {
return financialYear;
}
public void setFinancialYear(Integer financialYear) {
this.financialYear = financialYear;
}
public Integer getFinancialYearWeek() {
return financialYearWeek;
}
public void setFinancialYearWeek(Integer financialYearWeek) {
this.financialYearWeek = financialYearWeek;
}
public Date getFinancialYearStart() {
return financialYearStart;
}
public void setFinancialYearStart(Date financialYearStart) {
this.financialYearStart = financialYearStart;
}
public Date getFinancialYearEnd() {
return financialYearEnd;
}
public void setFinancialYearEnd(Date financialYearEnd) {
this.financialYearEnd = financialYearEnd;
}
public Date getWeekStartDay() {
return weekStartDay;
}
public void setWeekStartDay(Date weekStartDay) {
this.weekStartDay = weekStartDay;
}
public Date getWeekEndDay() {
return weekEndDay;
}
public void setWeekEndDay(Date weekEndDay) {
this.weekEndDay = weekEndDay;
}
public Integer getWeekInSeason() {
return weekInSeason;
}
public void setWeekInSeason(Integer weekInSeason) {
this.weekInSeason = weekInSeason;
}
}
...@@ -59,13 +59,15 @@ spring: ...@@ -59,13 +59,15 @@ spring:
# url: jdbc:mysql://localhost:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # url: jdbc:mysql://localhost:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://120.79.36.53:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai url: jdbc:mysql://120.79.36.53:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root username: root
# password: 716288qwe # password: 716288qwe
password: 15671628341Qwe. password: 15671628341Qwe.
ali-ds: ali-ds:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://120.79.36.53:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai url: jdbc:mysql://120.79.36.53:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root username: root
password: 15671628341Qwe. password: 15671628341Qwe.
seata:
tx-service-group: default_tx_group
#seata: #seata:
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true"> <configuration>
<property name="log.charset" value="utf-8"/>
<property name="console.log.pattern"
value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %blue(%msg%n)"/>
<property name="file.log.pattern"
value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>
<!-- 此xml在spring-boot-1.5.3.RELEASE.jar里 --> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<!--控制台打印日志,不需要配置appender了-->
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<!-- 开启后可以通过jmx动态控制日志级别(springboot Admin的功能) -->
<!--<jmxConfigurator/>-->
<!--总日志-->
<appender name="ALL-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--日志存放路径-->
<file>../logs/springboot-mybatis.log</file>
<encoder> <encoder>
<!-- pattern节点,用来设置日志的输入格式 --> <pattern>${console.log.pattern}</pattern>
<pattern>%date [%level] [%thread] %logger{60} [%file : %line] %msg%n</pattern> <charset>${log.charset}</charset>
<!--文件编码格式-->
<charset>UTF-8</charset>
</encoder> </encoder>
<!-- 滚动策略 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 添加.gz 历史日志会启用压缩 大大缩小日志文件所占空间 -->
<fileNamePattern>../logs/springboot-mybatis.log.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 保留30天日志 -->
<maxHistory>30</maxHistory>
<!--文件最大存储-->
<totalSizeCap>10GB</totalSizeCap>
</rollingPolicy>
</appender> </appender>
<!--错误日志--> <appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<appender name="ERROR-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>logs/SpringBoot-kwan.log</file>
<!--日志存放路径--> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<file>../logs/error.log</file> <fileNamePattern>
<encoder> logs/SpringBoot-kwan-%d{yyyy-MM-dd}.%i.log
<pattern>%date [%level] [%thread] %logger{60} [%file : %line] %msg%n</pattern> </fileNamePattern>
<!--文件编码格式--> <maxFileSize>128MB</maxFileSize>
<charset>UTF-8</charset>
</encoder>
<!-- 滚动策略 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 添加.gz 历史日志会启用压缩 大大缩小日志文件所占空间 -->
<fileNamePattern>../logs/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 保留30天日志 -->
<maxHistory>30</maxHistory> <maxHistory>30</maxHistory>
<!--文件最大存储--> <totalSizeCap>20GB</totalSizeCap>
<totalSizeCap>10GB</totalSizeCap>
</rollingPolicy> </rollingPolicy>
<!-- 过滤日志 --> <encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter"> <pattern>${file.log.pattern}</pattern>
<level>ERROR</level> <charset>${log.charset}</charset>
<!-- 用于配置符合过滤条件的操作 --> </encoder>
<onMatch>ACCEPT</onMatch>
<!-- 用于配置不符合过滤条件的操作 -->
<onMismatch>DENY</onMismatch>
</filter>
</appender> </appender>
<logger name="com.kwan.springbootkwan" level="INFO"/> <logger name="com.kwan.springbootkwan.mapper" level="info" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
<root level="INFO"> <root level="info">
<!--控制台打印日志--> <appender-ref ref="STDOUT"/>
<appender-ref ref="CONSOLE"/> <appender-ref ref="ROLLING"/>
<appender-ref ref="ALL-FILE"/>
<appender-ref ref="ERROR-FILE"/>
</root> </root>
</configuration> </configuration>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册