mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-23 05:00:25 +08:00
feat(logback-spring.xml):修改app-name
This commit is contained in:
parent
28c455715c
commit
f3260ff25d
@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil;
|
||||
import com.youlai.common.web.pojo.domain.OptLog;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.logstash.logback.marker.Markers;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.Signature;
|
||||
@ -29,9 +30,9 @@ import java.util.Map;
|
||||
@Aspect
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
public class LogAspect {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LogAspect.class);
|
||||
@Pointcut("@annotation(io.swagger.annotations.ApiOperation)")
|
||||
public void Log() {
|
||||
}
|
||||
@ -64,8 +65,7 @@ public class LogAspect {
|
||||
logMap.put("description",optLog.getDescription());
|
||||
logMap.put("result",result);
|
||||
|
||||
LOGGER.info("123");
|
||||
LOGGER.info(Markers.appendEntries(logMap),JSONUtil.parse(optLog).toString());
|
||||
log.info(Markers.appendEntries(logMap),JSONUtil.parse(optLog).toString());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1,69 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE configuration>
|
||||
<configuration>
|
||||
<!--引用默认日志配置-->
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||
<!--使用默认的控制台日志输出实现-->
|
||||
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||
<!--应用名称-->
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name" defaultValue="springBoot"/>
|
||||
<!--日志文件保存路径-->
|
||||
<property name="LOG_FILE_PATH" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/logs}"/>
|
||||
<!--LogStash访问host-->
|
||||
<springProperty name="LOG_STASH_HOST" scope="context" source="www.juxingtech.cn" defaultValue="www.juxingtech.cn"/>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
|
||||
<!--DEBUG日志输出到文件-->
|
||||
<appender name="FILE_DEBUG"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!--输出DEBUG以上级别日志-->
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>DEBUG</level>
|
||||
</filter>
|
||||
<!-- 属性 -->
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name" defaultValue="default"/>
|
||||
|
||||
<!--输出到控制台-->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<!--设置为默认的文件日志格式-->
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
<pattern>
|
||||
%d{yyyy-MM-dd HH:mm:ss.SSS}|%level|%logger|%thread|%X{traceId}|%m%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!--设置文件命名格式-->
|
||||
<fileNamePattern>${LOG_FILE_PATH}/debug/${APP_NAME}-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
|
||||
<!--设置日志文件大小,超过就重新生成文件,默认10M-->
|
||||
<maxFileSize>${LOG_FILE_MAX_SIZE:-10MB}</maxFileSize>
|
||||
<!--日志文件保留天数,默认30天-->
|
||||
<maxHistory>${LOG_FILE_MAX_HISTORY:-30}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<!--ERROR日志输出到文件-->
|
||||
<appender name="FILE_ERROR"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!--只输出ERROR级别的日志-->
|
||||
<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>UTF-8</charset>
|
||||
<!--开启tcp格式的logstash传输,通过TCP协议连接Logstash-->
|
||||
<appender name="STASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<destination>www.juxingtech.cn:4560</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
|
||||
<customFields>{"appname":"${APP_NAME}"}</customFields>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!--设置文件命名格式-->
|
||||
<fileNamePattern>${LOG_FILE_PATH}/error/${APP_NAME}-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
|
||||
<!--设置日志文件大小,超过就重新生成文件,默认10M-->
|
||||
<maxFileSize>${LOG_FILE_MAX_SIZE:-10MB}</maxFileSize>
|
||||
<!--日志文件保留天数,默认30天-->
|
||||
<maxHistory>${LOG_FILE_MAX_HISTORY:-30}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<!--DEBUG日志输出到LogStash-->
|
||||
<appender name="LOG_STASH_DEBUG" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>DEBUG</level>
|
||||
</filter>
|
||||
<destination>${LOG_STASH_HOST}:4560</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
@ -86,136 +41,11 @@
|
||||
</pattern>
|
||||
</providers>
|
||||
</encoder>
|
||||
<!--当有多个LogStash服务时,设置访问策略为轮询-->
|
||||
<connectionStrategy>
|
||||
<roundRobin>
|
||||
<connectionTTL>5 minutes</connectionTTL>
|
||||
</roundRobin>
|
||||
</connectionStrategy>
|
||||
<keepAliveDuration>5 minutes</keepAliveDuration>
|
||||
</appender>
|
||||
|
||||
<!--ERROR日志输出到LogStash-->
|
||||
<appender name="LOG_STASH_ERROR" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<destination>${LOG_STASH_HOST}:4560</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
<timeZone>Asia/Shanghai</timeZone>
|
||||
</timestamp>
|
||||
<!--自定义日志输出格式-->
|
||||
<pattern>
|
||||
<pattern>
|
||||
{
|
||||
"project": "youlai-mall",
|
||||
"level": "%level",
|
||||
"service": "${APP_NAME:-}",
|
||||
"pid": "${PID:-}",
|
||||
"thread": "%thread",
|
||||
"class": "%logger",
|
||||
"message": "%message",
|
||||
"stack_trace": "%exception{20}"
|
||||
}
|
||||
</pattern>
|
||||
</pattern>
|
||||
</providers>
|
||||
</encoder>
|
||||
<!--当有多个LogStash服务时,设置访问策略为轮询-->
|
||||
<connectionStrategy>
|
||||
<roundRobin>
|
||||
<connectionTTL>5 minutes</connectionTTL>
|
||||
</roundRobin>
|
||||
</connectionStrategy>
|
||||
</appender>
|
||||
|
||||
<!--业务日志输出到LogStash-->
|
||||
<appender name="LOG_STASH_BUSINESS" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<destination>${LOG_STASH_HOST}:4560</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
<timeZone>Asia/Shanghai</timeZone>
|
||||
</timestamp>
|
||||
<!--自定义日志输出格式-->
|
||||
<pattern>
|
||||
<pattern>
|
||||
{
|
||||
"project": "youlai-mall",
|
||||
"level": "%level",
|
||||
"service": "${APP_NAME:-}",
|
||||
"pid": "${PID:-}",
|
||||
"thread": "%thread",
|
||||
"class": "%logger",
|
||||
"message": "%message",
|
||||
"stack_trace": "%exception{20}"
|
||||
}
|
||||
</pattern>
|
||||
</pattern>
|
||||
</providers>
|
||||
</encoder>
|
||||
<!--当有多个LogStash服务时,设置访问策略为轮询-->
|
||||
<connectionStrategy>
|
||||
<roundRobin>
|
||||
<connectionTTL>5 minutes</connectionTTL>
|
||||
</roundRobin>
|
||||
</connectionStrategy>
|
||||
</appender>
|
||||
|
||||
<!--接口访问记录日志输出到LogStash-->
|
||||
<appender name="LOG_STASH_RECORD" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<destination>${LOG_STASH_HOST}:4560</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
<timeZone>Asia/Shanghai</timeZone>
|
||||
</timestamp>
|
||||
<!--自定义日志输出格式-->
|
||||
<pattern>
|
||||
<pattern>
|
||||
{
|
||||
"project": "youlai-mall",
|
||||
"level": "%level",
|
||||
"service": "${APP_NAME:-}",
|
||||
"class": "%logger",
|
||||
"message": "%message"
|
||||
}
|
||||
</pattern>
|
||||
</pattern>
|
||||
</providers>
|
||||
</encoder>
|
||||
<!--当有多个LogStash服务时,设置访问策略为轮询-->
|
||||
<connectionStrategy>
|
||||
<roundRobin>
|
||||
<connectionTTL>5 minutes</connectionTTL>
|
||||
</roundRobin>
|
||||
</connectionStrategy>
|
||||
</appender>
|
||||
|
||||
<!--控制框架输出日志-->
|
||||
<logger name="org.slf4j" level="INFO"/>
|
||||
<logger name="springfox" level="INFO"/>
|
||||
<logger name="io.swagger" level="INFO"/>
|
||||
<logger name="org.springframework" level="INFO"/>
|
||||
<logger name="org.hibernate.validator" level="INFO"/>
|
||||
<logger name="com.alibaba.nacos.client.naming" level="INFO"/>
|
||||
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="FILE_DEBUG"/>
|
||||
<appender-ref ref="FILE_ERROR"/>
|
||||
<appender-ref ref="LOG_STASH_DEBUG"/>
|
||||
<appender-ref ref="LOG_STASH_ERROR"/>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="STASH"/>
|
||||
</root>
|
||||
|
||||
<logger name="com.youlai.common.web.aspect.LogAspect" level="DEBUG">
|
||||
<appender-ref ref="LOG_STASH_RECORD"/>
|
||||
</logger>
|
||||
|
||||
<logger name="com.youlai" level="DEBUG">
|
||||
<appender-ref ref="LOG_STASH_BUSINESS"/>
|
||||
</logger>
|
||||
<logger name="io.seata" level="ERROR"></logger>
|
||||
</configuration>
|
||||
|
Loading…
Reference in New Issue
Block a user