eggjs / eggjs/egg

egg-logger设置outputJSON: true后,建议通过配置开启关闭原有日志格式文件

Open
#4,909 0 comments 0 reactions 0 assignees View on GitHub
Inactive
Dominant language
TypeScript
Stars
19k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

egg-logger设置outputJSON: true后,日志写了两份,原有格式的和json格式的,对于生产环境来说,太浪费了。建议通过配置开启关闭写入原有日志格式文件。
> common-error.json.log
> common-error.log
> edu-web.json.log
> edu-web.log
> egg-agent.json.log
> egg-agent.log
> egg-schedule.json.log
> egg-schedule.log
> egg-web.json.log
> egg-web.log

如果侵入式修改这个文件,感觉不合适。
https://github.com/eggjs/egg-logger/blob/master/lib/egg/logger.js
```
const fileTransport = new EggFileTransport({
file: this.options.file,
level: this.options.level || 'INFO',
encoding: this.options.encoding,
formatter: this.options.formatter,
contextFormatter: this.options.contextFormatter,
flushInterval: this.options.flushInterval,
eol: this.options.eol,
});
this.set('file', fileTransport);

if (this.options.jsonFile) {
const jsonFileTransport = new EggFileTransport({
file: this.options.jsonFile,
level: this.options.level,
encoding: this.options.encoding,
flushInterval: this.options.flushInterval,
json: true,
eol: this.options.eol,
});
this.set('jsonFile', jsonFileTransport);
}
```
或者有没有其他较好的方式关闭原有格式的日志写入?

谢谢!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.