We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1、项目说明: midway v3 + koa 1、期望效果:将所有应用日志均输出为JSON格式。 2、实际效果:仅midway-core日志生效。 midway-core.json.log: {"timestamp":"2024-08-27 11:18:48.159","level":"info","pid":42469,"message":"[midway:redis] client connect success"} midway-cron.json.log: 2024-08-27 11:18:00.048 ERROR 41827 [DailyAnalyzeJob] 出错了
{"timestamp":"2024-08-27 11:18:48.159","level":"info","pid":42469,"message":"[midway:redis] client connect success"}
2024-08-27 11:18:00.048 ERROR 41827 [DailyAnalyzeJob] 出错了
3、config.default.ts代码实例:
midwayLogger: { default: { level: 'warn', dir: path.join(appInfo.baseDir, './../logs/'), transports: { console: false, error: { fileLogName: 'common-error.json.log', }, }, format: (info: LoggerInfo) => { const { timestamp, level, pid, message } = info; return JSON.stringify({ timestamp, level, pid, message, }); }, }, clients: { coreLogger: { fileLogName: 'midway-core.json.log', }, appLogger: { fileLogName: 'midway-web.json.log', }, agentLogger: { fileLogName: 'midway-agent.json.log', }, cronLogger: { fileLogName: 'midway-cron.json.log', }, }, }
4、日志输出方式:
import { ILogger } from '@midwayjs/logger'; @Inject() logger: ILogger; this.logger.error(err)
5、补充说明:通过手动设置修改Koa上下文日志格式,可以在请求时让conmon-error日志中输出JSON格式,但是在job定时任务里面依然无法输出JSON格式。
koa: { ... contextLoggerFormat: (info: LoggerInfo) => { const { timestamp, level, pid, message } = info; return JSON.stringify({ timestamp, level, pid, message, }); }, },
The text was updated successfully, but these errors were encountered:
需要关闭 file,开启 json ?
midwayLogger: { default: { level: 'warn', dir: path.join(appInfo.baseDir, './../logs/'), transports: { console: false, file: false, json:{ // ... }, }
Sorry, something went wrong.
No branches or pull requests
1、项目说明: midway v3 + koa
1、期望效果:将所有应用日志均输出为JSON格式。
2、实际效果:仅midway-core日志生效。
midway-core.json.log:
{"timestamp":"2024-08-27 11:18:48.159","level":"info","pid":42469,"message":"[midway:redis] client connect success"}
midway-cron.json.log:
2024-08-27 11:18:00.048 ERROR 41827 [DailyAnalyzeJob] 出错了
3、config.default.ts代码实例:
4、日志输出方式:
5、补充说明:通过手动设置修改Koa上下文日志格式,可以在请求时让conmon-error日志中输出JSON格式,但是在job定时任务里面依然无法输出JSON格式。
The text was updated successfully, but these errors were encountered: