mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-05 20:08:05 +00:00
update 任务调度 独立 ruoyi-job 服务 统一远程处理任务 规范用法
This commit is contained in:
15
ruoyi-modules/ruoyi-job/Dockerfile
Normal file
15
ruoyi-modules/ruoyi-job/Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM anapsix/alpine-java:8_server-jre_unlimited
|
||||
|
||||
MAINTAINER Lion Li
|
||||
|
||||
RUN mkdir -p /ruoyi/job
|
||||
RUN mkdir -p /ruoyi/job/logs
|
||||
RUN mkdir -p /ruoyi/job/temp
|
||||
|
||||
WORKDIR /ruoyi/job
|
||||
|
||||
EXPOSE 9203
|
||||
|
||||
ADD ./target/ruoyi-job.jar ./app.jar
|
||||
|
||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
|
116
ruoyi-modules/ruoyi-job/pom.xml
Normal file
116
ruoyi-modules/ruoyi-job/pom.xml
Normal file
@@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
<version>0.7.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-job</artifactId>
|
||||
|
||||
<description>
|
||||
ruoyi-job 任务调度模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-dict</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-dubbo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-seata</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-job</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Api System -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-api-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@@ -0,0 +1,23 @@
|
||||
package com.ruoyi.job;
|
||||
|
||||
import com.ruoyi.common.security.annotation.EnableCustomConfig;
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 任务调度模块
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableDubbo
|
||||
@SpringBootApplication
|
||||
public class RuoYiJobApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RuoYiJobApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 任务调度模块启动成功 ლ(´ڡ`ლ)゙ ");
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package com.ruoyi.job.service;
|
||||
|
||||
import com.ruoyi.system.api.RemoteUserService;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import com.ruoyi.system.api.model.LoginUser;
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* XxlJob 多服务调用
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MultiService {
|
||||
|
||||
@DubboReference
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
/**
|
||||
* 多服务调用
|
||||
*/
|
||||
@GlobalTransactional(rollbackFor = Exception.class)
|
||||
@XxlJob("multiServiceHandler")
|
||||
public void multiServiceHandler() throws Exception {
|
||||
LoginUser admin = remoteUserService.getUserInfo("admin");
|
||||
XxlJobHelper.log("XXL-JOB, multiServiceHandler result: {}", admin.toString());
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserName("test");
|
||||
sysUser.setNickName("test");
|
||||
remoteUserService.registerUserInfo(sysUser);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,254 @@
|
||||
package com.ruoyi.job.service;
|
||||
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* XxlJob开发示例(Bean模式)
|
||||
* <p>
|
||||
* 开发步骤:
|
||||
* 1、任务开发:在Spring Bean实例中,开发Job方法;
|
||||
* 2、注解配置:为Job方法添加注解 "@XxlJob(value="自定义jobhandler名称", init = "JobHandler初始化方法", destroy = "JobHandler销毁方法")",注解value值对应的是调度中心新建任务的JobHandler属性的值。
|
||||
* 3、执行日志:需要通过 "XxlJobHelper.log" 打印执行日志;
|
||||
* 4、任务结果:默认任务结果为 "成功" 状态,不需要主动设置;如有诉求,比如设置任务结果为失败,可以通过 "XxlJobHelper.handleFail/handleSuccess" 自主设置任务结果;
|
||||
*
|
||||
* @author xuxueli 2019-12-11 21:52:51
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SampleService {
|
||||
|
||||
|
||||
/**
|
||||
* 1、简单任务示例(Bean模式)
|
||||
*/
|
||||
@XxlJob("demoJobHandler")
|
||||
public void demoJobHandler() throws Exception {
|
||||
XxlJobHelper.log("XXL-JOB, Hello World.");
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
XxlJobHelper.log("beat at:" + i);
|
||||
TimeUnit.SECONDS.sleep(2);
|
||||
}
|
||||
// default success
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 2、分片广播任务
|
||||
*/
|
||||
@XxlJob("shardingJobHandler")
|
||||
public void shardingJobHandler() throws Exception {
|
||||
|
||||
// 分片参数
|
||||
int shardIndex = XxlJobHelper.getShardIndex();
|
||||
int shardTotal = XxlJobHelper.getShardTotal();
|
||||
|
||||
XxlJobHelper.log("分片参数:当前分片序号 = {}, 总分片数 = {}", shardIndex, shardTotal);
|
||||
|
||||
// 业务逻辑
|
||||
for (int i = 0; i < shardTotal; i++) {
|
||||
if (i == shardIndex) {
|
||||
XxlJobHelper.log("第 {} 片, 命中分片开始处理", i);
|
||||
} else {
|
||||
XxlJobHelper.log("第 {} 片, 忽略", i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 3、命令行任务
|
||||
*/
|
||||
@XxlJob("commandJobHandler")
|
||||
public void commandJobHandler() throws Exception {
|
||||
String command = XxlJobHelper.getJobParam();
|
||||
int exitValue = -1;
|
||||
|
||||
BufferedReader bufferedReader = null;
|
||||
try {
|
||||
// command process
|
||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||
processBuilder.command(command);
|
||||
processBuilder.redirectErrorStream(true);
|
||||
|
||||
Process process = processBuilder.start();
|
||||
//Process process = Runtime.getRuntime().exec(command);
|
||||
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(process.getInputStream());
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(bufferedInputStream));
|
||||
|
||||
// command log
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
XxlJobHelper.log(line);
|
||||
}
|
||||
|
||||
// command exit
|
||||
process.waitFor();
|
||||
exitValue = process.exitValue();
|
||||
} catch (Exception e) {
|
||||
XxlJobHelper.log(e);
|
||||
} finally {
|
||||
if (bufferedReader != null) {
|
||||
bufferedReader.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (exitValue == 0) {
|
||||
// default success
|
||||
} else {
|
||||
XxlJobHelper.handleFail("command exit value(" + exitValue + ") is failed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 4、跨平台Http任务
|
||||
* 参数示例:
|
||||
* "url: http://www.baidu.com\n" +
|
||||
* "method: get\n" +
|
||||
* "data: content\n";
|
||||
*/
|
||||
@XxlJob("httpJobHandler")
|
||||
public void httpJobHandler() throws Exception {
|
||||
|
||||
// param parse
|
||||
String param = XxlJobHelper.getJobParam();
|
||||
if (param == null || param.trim().length() == 0) {
|
||||
XxlJobHelper.log("param[" + param + "] invalid.");
|
||||
|
||||
XxlJobHelper.handleFail();
|
||||
return;
|
||||
}
|
||||
|
||||
String[] httpParams = param.split("\n");
|
||||
String url = null;
|
||||
String method = null;
|
||||
String data = null;
|
||||
for (String httpParam : httpParams) {
|
||||
if (httpParam.startsWith("url:")) {
|
||||
url = httpParam.substring(httpParam.indexOf("url:") + 4).trim();
|
||||
}
|
||||
if (httpParam.startsWith("method:")) {
|
||||
method = httpParam.substring(httpParam.indexOf("method:") + 7).trim().toUpperCase();
|
||||
}
|
||||
if (httpParam.startsWith("data:")) {
|
||||
data = httpParam.substring(httpParam.indexOf("data:") + 5).trim();
|
||||
}
|
||||
}
|
||||
|
||||
// param valid
|
||||
if (url == null || url.trim().length() == 0) {
|
||||
XxlJobHelper.log("url[" + url + "] invalid.");
|
||||
|
||||
XxlJobHelper.handleFail();
|
||||
return;
|
||||
}
|
||||
if (method == null || !Arrays.asList("GET", "POST").contains(method)) {
|
||||
XxlJobHelper.log("method[" + method + "] invalid.");
|
||||
|
||||
XxlJobHelper.handleFail();
|
||||
return;
|
||||
}
|
||||
boolean isPostMethod = method.equals("POST");
|
||||
|
||||
// request
|
||||
HttpURLConnection connection = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
try {
|
||||
// connection
|
||||
URL realUrl = new URL(url);
|
||||
connection = (HttpURLConnection) realUrl.openConnection();
|
||||
|
||||
// connection setting
|
||||
connection.setRequestMethod(method);
|
||||
connection.setDoOutput(isPostMethod);
|
||||
connection.setDoInput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setReadTimeout(5 * 1000);
|
||||
connection.setConnectTimeout(3 * 1000);
|
||||
connection.setRequestProperty("connection", "Keep-Alive");
|
||||
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
|
||||
connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");
|
||||
|
||||
// do connection
|
||||
connection.connect();
|
||||
|
||||
// data
|
||||
if (isPostMethod && data != null && data.trim().length() > 0) {
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream());
|
||||
dataOutputStream.write(data.getBytes("UTF-8"));
|
||||
dataOutputStream.flush();
|
||||
dataOutputStream.close();
|
||||
}
|
||||
|
||||
// valid StatusCode
|
||||
int statusCode = connection.getResponseCode();
|
||||
if (statusCode != 200) {
|
||||
throw new RuntimeException("Http Request StatusCode(" + statusCode + ") Invalid.");
|
||||
}
|
||||
|
||||
// result
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
String responseMsg = result.toString();
|
||||
|
||||
XxlJobHelper.log(responseMsg);
|
||||
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
XxlJobHelper.log(e);
|
||||
|
||||
XxlJobHelper.handleFail();
|
||||
return;
|
||||
} finally {
|
||||
try {
|
||||
if (bufferedReader != null) {
|
||||
bufferedReader.close();
|
||||
}
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
XxlJobHelper.log(e2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 5、生命周期任务示例:任务初始化与销毁时,支持自定义相关逻辑;
|
||||
*/
|
||||
@XxlJob(value = "demoJobHandler2", init = "init", destroy = "destroy")
|
||||
public void demoJobHandler2() throws Exception {
|
||||
XxlJobHelper.log("XXL-JOB, Hello World.");
|
||||
}
|
||||
|
||||
public void init() {
|
||||
log.info("init");
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
log.info("destory");
|
||||
}
|
||||
|
||||
|
||||
}
|
10
ruoyi-modules/ruoyi-job/src/main/resources/banner.txt
Normal file
10
ruoyi-modules/ruoyi-job/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
_ _ _
|
||||
(_) (_) | |
|
||||
_ __ _ _ ___ _ _ _ ______ _ ___ | |__
|
||||
| '__| | | |/ _ \| | | | |______| |/ _ \| '_ \
|
||||
| | | |_| | (_) | |_| | | | | (_) | |_) |
|
||||
|_| \__,_|\___/ \__, |_| | |\___/|_.__/
|
||||
__/ | _/ |
|
||||
|___/ |__/
|
38
ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml
Normal file
38
ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
# Tomcat
|
||||
server:
|
||||
port: 9203
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
# 此配置禁止放入 nacos 优先级不够
|
||||
allow-circular-references: true
|
||||
application:
|
||||
# 应用名称
|
||||
name: ruoyi-job
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: @profiles.active@
|
||||
|
||||
--- # nacos 配置
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
# nacos 服务地址
|
||||
server-addr: @nacos.server@
|
||||
discovery:
|
||||
# 注册组
|
||||
group: @nacos.discovery.group@
|
||||
namespace: ${spring.profiles.active}
|
||||
config:
|
||||
# 配置组
|
||||
group: @nacos.config.group@
|
||||
namespace: ${spring.profiles.active}
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- data-id: application.${spring.cloud.nacos.config.file-extension}
|
||||
refresh: true
|
||||
- data-id: datasource.${spring.cloud.nacos.config.file-extension}
|
||||
refresh: true
|
97
ruoyi-modules/ruoyi-job/src/main/resources/logback.xml
Normal file
97
ruoyi-modules/ruoyi-job/src/main/resources/logback.xml
Normal file
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/ruoyi-job" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="console.log.pattern"
|
||||
value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
|
||||
<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${console.log.pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="file_console" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/console.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/console.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大 1天 -->
|
||||
<maxHistory>1</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.ruoyi" level="info" />
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
<appender-ref ref="file_console" />
|
||||
</root>
|
||||
</configuration>
|
Reference in New Issue
Block a user