Skip to content

nuxt3-winston-log

安装

bash
pnpm install nuxt3-winston-log -S

配置

  • nuxt.config.js
ts
modules: [
        'nuxt3-winston-log'
    ],

最后一步写入配置

ts
  nuxt3WinstonLog: {
        // 配置项
        // Maximum size of the file after which it will log
        // This can be a number of bytes, or units of kb, mb, and gb
        // If using the units, add 'k', 'm', or 'g' as the suffix. The units need to directly follow the number
        maxSize: '1m',

        // Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days
        // If using days, add 'd' as the suffix. It uses auditFile to keep track of the log files in a json format
        // It won't delete any file not contained in it. It can be a number of files or number of days
        maxFiles: '100d',

        // Path that info log files will be created in.
        // Change this to keep things neat.
        infoLogPath: `./logs`,

        // Name of info log file.
        // Change this to keep things tidy.
        infoLogName: `%DATE%-${process.env.NODE_ENV}-info.log`,

        // Path that error log files will be created in.
        // Change this to keep things neat.
        errorLogPath: `./logs`,

        // Name of error log file.
        // Change this to keep things tidy.
        errorLogName: `%DATE%-${process.env.NODE_ENV}-error.log`,

        // Set to `true` to skip auto render:html logging (level: info).
        skipRequestMiddlewareHandler: false
    },
  • 全部日志代码
ts
export default defineNuxtConfig({
  modules: ["nuxt3-winston-log"],
  nuxt3WinstonLog: {
    maxSize: "2048m",
    maxFiles: "30d",
  },
});