fix:修改日志

上级 73cca3e4
package com.kwan.springbootkwan.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
......@@ -13,21 +14,22 @@ import javax.servlet.http.HttpServletResponse;
* @version : 2.2.0
* @date : 2022/12/19 16:14
*/
@Slf4j
public class MyInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
System.out.println("MyInterceptor>>>>>>>>>preHandle");
log.info("MyInterceptor>>>>>>>>>preHandle");
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
System.out.println("MyInterceptor>>>>>>>>>postHandle");
log.info("MyInterceptor>>>>>>>>>postHandle");
}
@Override
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;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
......@@ -10,13 +11,14 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Slf4j
@Configuration
public class RedisConfig {
@Bean
@SuppressWarnings("all")
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
System.out.println("==================自定义的redisTemplate实例化了===================");
log.info("==================自定义的redisTemplate实例化了===================");
RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
template.setConnectionFactory(factory);
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
......
package com.kwan.springbootkwan.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@TableName(value = "ads_dim_financial_year_week_info")
@Data
@ApiModel(value = "财年周")
public class AdsDimFinancialYearWeekInfo extends Model<AdsDimFinancialYearWeekInfo> {
//财年
@TableId
@ApiModelProperty(value = "财年")
private Integer financialYear;
//第n财年周
@ApiModelProperty(value = "第n财年周")
private Integer financialYearWeek;
//财年开始日期
@ApiModelProperty(value = "财年开始日期")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date financialYearStart;
//财年结束日期
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "财年结束日期")
private Date financialYearEnd;
//周开始
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "周开始")
private Date weekStartDay;
//周结束
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "周结束")
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;
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;
}
}
\ No newline at end of file
......@@ -59,13 +59,15 @@ spring:
# 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
username: root
# password: 716288qwe
# password: 716288qwe
password: 15671628341Qwe.
ali-ds:
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
username: root
password: 15671628341Qwe.
seata:
tx-service-group: default_tx_group
#seata:
......
<?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里 -->
<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>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!-- pattern节点,用来设置日志的输入格式 -->
<pattern>%date [%level] [%thread] %logger{60} [%file : %line] %msg%n</pattern>
<!--文件编码格式-->
<charset>UTF-8</charset>
<pattern>${console.log.pattern}</pattern>
<charset>${log.charset}</charset>
</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 name="ERROR-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--日志存放路径-->
<file>../logs/error.log</file>
<encoder>
<pattern>%date [%level] [%thread] %logger{60} [%file : %line] %msg%n</pattern>
<!--文件编码格式-->
<charset>UTF-8</charset>
</encoder>
<!-- 滚动策略 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 添加.gz 历史日志会启用压缩 大大缩小日志文件所占空间 -->
<fileNamePattern>../logs/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 保留30天日志 -->
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/SpringBoot-kwan.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>
logs/SpringBoot-kwan-%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxFileSize>128MB</maxFileSize>
<maxHistory>30</maxHistory>
<!--文件最大存储-->
<totalSizeCap>10GB</totalSizeCap>
<totalSizeCap>20GB</totalSizeCap>
</rollingPolicy>
<!-- 过滤日志 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<!-- 用于配置符合过滤条件的操作 -->
<onMatch>ACCEPT</onMatch>
<!-- 用于配置不符合过滤条件的操作 -->
<onMismatch>DENY</onMismatch>
</filter>
<encoder>
<pattern>${file.log.pattern}</pattern>
<charset>${log.charset}</charset>
</encoder>
</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">
<!--控制台打印日志-->
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ALL-FILE"/>
<appender-ref ref="ERROR-FILE"/>
<root level="info">
<appender-ref ref="STDOUT"/>
<appender-ref ref="ROLLING"/>
</root>
</configuration>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册