优化:降低访问日志噪声并增加日志文件轮转
This commit is contained in:
@@ -19,6 +19,8 @@ export function createDefaultRuntimeConfig(projectRoot: string): RuntimeConfig {
|
||||
// 对接日志默认只保留 warn/error,避免 integration-*.log 被 info 刷爆
|
||||
integrationLevel: 'warn',
|
||||
retentionDays: 30,
|
||||
maxFileSizeMb: 20,
|
||||
maxFiles: 5,
|
||||
},
|
||||
|
||||
retention: {
|
||||
|
||||
@@ -13,6 +13,8 @@ test('applyEnvOverrides maps typed environment values without mutating base conf
|
||||
DATA_ROOT: './tmp/backend-data',
|
||||
DATABASE_SSL: 'yes',
|
||||
LOG_RETENTION_DAYS: '45',
|
||||
LOG_MAX_FILE_SIZE_MB: '12',
|
||||
LOG_MAX_FILES: '4',
|
||||
ADMIN_DEFAULT_USERS_JSON: '[{"username":"admin","password":"secret","role":"admin"}]',
|
||||
KAQUAN91_USER_ID: 'kaquan-user',
|
||||
KAQUAN91_SECRET: 'kaquan-secret',
|
||||
@@ -23,6 +25,8 @@ test('applyEnvOverrides maps typed environment values without mutating base conf
|
||||
assert.equal(config.data.root, path.resolve('./tmp/backend-data'))
|
||||
assert.equal(config.database.ssl, true)
|
||||
assert.equal(config.logging.retentionDays, 45)
|
||||
assert.equal(config.logging.maxFileSizeMb, 12)
|
||||
assert.equal(config.logging.maxFiles, 4)
|
||||
assert.deepEqual(config.admin.defaultUsers, [
|
||||
{ username: 'admin', password: 'secret', role: 'admin' },
|
||||
])
|
||||
|
||||
@@ -33,6 +33,8 @@ export const ENV_OVERRIDES: readonly EnvOverride[] = [
|
||||
stringEnv('LOG_LEVEL', ['logging', 'level']),
|
||||
stringEnv('LOG_INTEGRATION_LEVEL', ['logging', 'integrationLevel']),
|
||||
integerEnv('LOG_RETENTION_DAYS', ['logging', 'retentionDays']),
|
||||
integerEnv('LOG_MAX_FILE_SIZE_MB', ['logging', 'maxFileSizeMb']),
|
||||
integerEnv('LOG_MAX_FILES', ['logging', 'maxFiles']),
|
||||
integerEnv('RAW_PAYLOAD_RETENTION_DAYS', ['retention', 'rawPayloadDays']),
|
||||
integerEnv('TASK_EVENT_RETENTION_DAYS', ['retention', 'taskEventDays']),
|
||||
integerEnv('WEBHOOK_EVENT_RETENTION_DAYS', ['retention', 'webhookEventDays']),
|
||||
|
||||
@@ -52,6 +52,8 @@ export function validateRuntimeConfig(
|
||||
})
|
||||
}
|
||||
requireInteger(issues, 'database.maxConnections', config.database?.maxConnections, { min: 1 })
|
||||
requireOptionalInteger(issues, 'logging.maxFileSizeMb', config.logging?.maxFileSizeMb, { min: 1 })
|
||||
requireOptionalInteger(issues, 'logging.maxFiles', config.logging?.maxFiles, { min: 2 })
|
||||
requireOptionalInteger(issues, 'database.idleTimeoutMs', config.database?.idleTimeoutMs, {
|
||||
min: 1,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user