midwayjs / logger

midway logger
MIT License
4 stars 3 forks source link

自定义日志设置日志格式化不生效 #116

Closed tuohuang closed 9 months ago

tuohuang commented 9 months ago
midwayLogger: {
    default: {
      transports: {
        file: {
          maxSize: '100m',
          // 也可以配置数字,表示最多保留日志文件的个数。
          maxFiles: '10d',
        },
        error: {
          maxSize: '100m',
          maxFiles: '10d',
        },
      }
    },
    clients: {
      coreLogger: {
        fileLogName: 'core.log',
      },
      appLogger: {
        fileLogName: 'app.log',
      },
      // bull的日志文件名
      bullLogger: {
        fileLogName: 'bull.log',
      },
      customLogger: {
        fileLogName: 'custom.log',
        contextFormat: (info) => {
          const ctx = info.ctx;
          console.log("++++++++++++++++")
          console.log(`${info.LEVEL} ${info.timestamp} ${info.message}`)
          return `${info.LEVEL} ${info.timestamp}  ${info.message}`;
        }
      },
    }
  },