Browse Source

修改日志级别

master
liuchen864 8 months ago
parent
commit
d31c051d5b
  1. 42
      src/main/java/com/win/mq/rocket/ChangchunWmsConsumer.java
  2. 121
      src/main/resources/logback-spring.xml

42
src/main/java/com/win/mq/rocket/ChangchunWmsConsumer.java

@ -0,0 +1,42 @@
package com.win.mq.rocket;
import com.win.mq.config.SmfsConfigure;
import com.win.mq.utils.sfms.AccessTokenUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
@Slf4j
@Component
public class ChangchunWmsConsumer {
@Autowired
private AccessTokenUtil accessTokenUtil;
@Autowired
private SmfsConfigure smfsConfigure;
@Autowired
private RestTemplate restTemplate;
@Component
@RocketMQMessageListener(topic = "SupplierDeliverRecord", consumerGroup = "SupplierDeliverRecord", selectorExpression="ChangchunWms")
class RocketMQConsumerWms implements RocketMQListener<String> {
public void onMessage(String message) {
//获取token,调用采购订单接口
//AccessTokenVO accessTokenVO = accessTokenUtil.getAccessTokenVO();
//log.info(accessTokenVO.toString());
//HttpHeaders headers = new HttpHeaders();
//headers.setContentType(MediaType.APPLICATION_JSON);
//headers.add(HttpHeaders.AUTHORIZATION, "Bearer " + accessTokenVO.getAccessToken());
//headers.add("tenant-id", "1");
// 将JSON参数转换成HttpEntity对象
//HttpEntity<String> requestEntity = new HttpEntity<>(message, headers);
// 发起POST请求
//ResponseEntity<String> responseEntity = restTemplate.postForEntity(smfsConfigure.getPurchaseOrder(), requestEntity, String.class);
log.info("RocketMQConsumerWms received message: " + message);
}
}
}

121
src/main/resources/logback-spring.xml

@ -27,6 +27,29 @@
</encoder> </encoder>
</appender> </appender>
<!-- 系统日志输出 -->
<appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-debug.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-debug.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 7天 -->
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>DEBUG</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统日志输出 --> <!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file> <file>${log.path}/sys-info.log</file>
@ -34,8 +57,8 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 --> <!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern> <fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60--> <!-- 日志最大的历史 7-->
<maxHistory>60</maxHistory> <maxHistory>7</maxHistory>
</rollingPolicy> </rollingPolicy>
<encoder> <encoder>
<pattern>${log.pattern}</pattern> <pattern>${log.pattern}</pattern>
@ -50,21 +73,22 @@
</filter> </filter>
</appender> </appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!-- 系统日志输出 -->
<file>${log.path}/sys-error.log</file> <appender name="file_warn" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-warn.log</file>
<!-- 循环政策:基于时间创建日志文件 --> <!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 --> <!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern> <fileNamePattern>${log.path}/sys-warn.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60--> <!-- 日志最大的历史 7-->
<maxHistory>60</maxHistory> <maxHistory>7</maxHistory>
</rollingPolicy> </rollingPolicy>
<encoder> <encoder>
<pattern>${log.pattern}</pattern> <pattern>${log.pattern}</pattern>
</encoder> </encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter"> <filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 --> <!-- 过滤的级别 -->
<level>ERROR</level> <level>WARN</level>
<!-- 匹配时的操作:接收(记录) --> <!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch> <onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) --> <!-- 不匹配时的操作:拒绝(不记录) -->
@ -72,37 +96,68 @@
</filter> </filter>
</appender> </appender>
<!-- 用户访问日志输出 --> <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.path}/sys-error.log</file>
<file>${log.path}/sys-user.log</file> <!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily --> <!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern> <fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60--> <!-- 日志最大的历史 7-->
<maxHistory>60</maxHistory> <maxHistory>7</maxHistory>
</rollingPolicy> </rollingPolicy>
<encoder> <encoder>
<pattern>${log.pattern}</pattern> <pattern>${log.pattern}</pattern>
</encoder> </encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:接收(记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender> </appender>
<!-- 系统模块日志级别控制 --> <!-- dev环境 -->
<logger name="com.win" level="info" /> <springProfile name="local,dev,default">
<!-- Spring日志级别控制 --> <root level="DEBUG">
<logger name="org.springframework" level="warn" /> <appender-ref ref="console"/>
<appender-ref ref="file_debug"/>
<root level="error"> <appender-ref ref="file_info"/>
<appender-ref ref="console" /> <appender-ref ref="file_warn"/>
</root> <appender-ref ref="file_error"/>
</root>
<!--系统操作日志--> </springProfile>
<root level="info"> <!-- test环境 -->
<appender-ref ref="file_info" /> <springProfile name="test">
<appender-ref ref="file_error" /> <root level="INFO">
</root> <appender-ref ref="console"/>
<appender-ref ref="file_info"/>
<appender-ref ref="file_warn"/>
<appender-ref ref="file_error"/>
</root>
</springProfile>
<!-- prod环境 -->
<springProfile name="prod">
<root level="INFO">
<appender-ref ref="file_info"/>
<appender-ref ref="file_warn"/>
<appender-ref ref="file_error"/>
</root>
</springProfile>
<!-- 指定第三方日志级别 -->
<logger name="org.springframework" level="WARN" />
<logger name="org.apache" level="INFO" />
<logger name="com.baomidou" level="INFO" />
<logger name="org.mybatis" level="INFO" />
<logger name="org.hibernate" level="INFO" />
<logger name="com.win.module.eam.controller" level="INFO" />
<logger name="io.netty" level="WARN" />
<logger name="org.redisson" level="WARN" />
<logger name="org.mapstruct" level="WARN" />
<logger name="org.flowable" level="WARN" />
<logger name="reactor.netty" level="WARN" />
<logger name="de.codecentric.boot" level="WARN" />
<logger name="com.alibaba" level="WARN" />
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration> </configuration>
Loading…
Cancel
Save