feature: 新增日志文件大小限制功能 (#445)

pull/448/head
王良 2025-02-05 13:13:25 +08:00 committed by GitHub
parent 3091bc06bb
commit b533427313
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 1 deletions

View File

@ -37,6 +37,8 @@ const defaultConfig = {
// 日志相关配置
logFileSavePath: path.join(configLoader.getUserBasePath(), '/logs'), // 日志文件保存路径
keepLogFileCount: 15, // 保留日志文件数
maxLogFileSize: 0, // 最大日志文件大小
maxLogFileSizeUnit: 'GB', // 最大日志文件大小单位
},
server: {
enabled: true,

View File

@ -29,6 +29,7 @@ const appenderConfig = {
compress: true, // 压缩日志文件
keepFileExt: true, // 保留日志文件扩展名为 .log
backups: configFromFiles.app.keepLogFileCount, // 保留日志文件数
maxLogSize: (configFromFiles.app.maxLogFileSize || 0) * 1024 * 1024 * (configFromFiles.app.maxLogFileSizeUnit === 'GB' ? 1024 : 1), // 目前单位只有GB和MB
}
let log = null

View File

@ -13,6 +13,16 @@ export default {
reloadLoading: false,
urlBackup: null,
personalUrlBackup: null,
maxLogFileSizeUnit: [
{
label: 'GB',
value: 'GB',
},
{
label: 'MB',
value: 'MB',
},
],
}
},
methods: {
@ -458,10 +468,22 @@ export default {
注意原目录中的文件不会自动转移到新的目录请自行转移或删除
</div>
</a-form-item>
<a-form-item label="最大日志文件大小" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-input-number v-model="config.app.maxLogFileSize" :step="1" :min="0" />
<a-select v-model="config.app.maxLogFileSizeUnit" class="md-ml-5">
<a-select-option v-for="(item) of maxLogFileSizeUnit" :key="item.value" :value="item.value">
{{ item.label }}
</a-select-option>
</a-select>
<div class="form-help">
修改后重启DS才生效<br>
单个日志文件的大小限制达到限制时会执行备份和清理程序配置为0时表示不限制大小
</div>
</a-form-item>
<a-form-item label="保留日志文件数" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-input-number v-model="config.app.keepLogFileCount" :step="1" :min="0" />
<div class="form-help">
修改后重启DS才生效隔天才会清理多余的历史日志文件
修改后重启DS才生效<code>隔天</code><code>达到日志大小限制</code>才会触发清理程序
</div>
</a-form-item>
</div>