zoukankan      html  css  js  c++  java
  • winston 日志管理4

    配置File Transport

    winston.add(winston.transports.File, options)

    The File transport should really be the 'Stream' transport since it will accept any WritableStream. It is named such because it will also accept filenames via the 'filename' option:

    • level: Level of messages that this transport should log.
    • silent: Boolean flag indicating whether to suppress output.
    • colorize: Boolean flag indicating if we should colorize output.
    • timestamp: Boolean flag indicating if we should prepend output with timestamps (default true). If function is specified, its return value will be used instead of timestamps.
    • filename: The filename of the logfile to write output to.
    • maxsize: Max size in bytes of the logfile, if the size is exceeded then a new file is created, a counter will become a suffix of the log file.
    • maxFiles: Limit the number of files created when the size of the logfile is exceeded.
    • stream: The WriteableStream to write output to.
    • json: If true, messages will be logged as JSON (default true).
    • eol: string indicating the end-of-line characters to use (default to  ).
    • prettyPrint: If true, additional JSON metadata objects that are added to logging string messages will be displayed as a JSON string representation. If function is specified, its return value will be the string representing the meta.
    • depth Numeric indicating how many times to recurse while formatting the object with util.inspect (only used with prettyPrint: true) (default null, unlimited)
    • logstash: If true, messages will be logged as JSON and formatted for logstash (default false).
    • showLevel: Boolean flag indicating if we should prepend output with level (default true).
    • formatter: If function is specified and json is set to false, its return value will be used instead of default output. (default undefined)
    • tailable: If true, log files will be rolled based on maxsize and maxfiles, but in ascending order. The filenamewill always have the most recent log lines. The larger the appended number, the older the log file. This option requires maxFiles to be set, or it will be ignored.
    • maxRetries: The number of stream creation retry attempts before entering a failed state. In a failed state the transport stays active but performs a NOOP on it's log function. (default 2)
    • zippedArchive: If true, all log files but the current one will be zipped.
    • options: options passed to fs.createWriteStream (default {flags: 'a'}).

    Metadata: Logged via util.inspect(meta);

  • 相关阅读:
    [云计算&大数据]概念辨析:数据仓库 | 数据湖 | 数据中心 | 数据中台 | 数据平台 【待续】
    [云计算]概念辨析:云计算 [IaaS/PaaS/SaaS & 公有云/私有云/混合云]
    [Linux]浅析"command > /dev/null 2>&1 &" 与 "command 1>/dev/null 2>&1 &"
    [Python]【Form Data vs Request Payload】之 python 爬虫如何实现 POST request payload 形式的请求
    [Python]PyCharm中出现unresolved reference的解决方法
    [数据库/MYSQL]MYSQL开启Bin-Log
    scrapy采集gb2312网页中文乱码笔记
    uTools 桌面软件。
    Asp.Net Core Grpc 入门实践
    ASP.NET Core 中间件(Middleware)(一)
  • 原文地址:https://www.cnblogs.com/jay--zhang/p/5980671.html
Copyright © 2011-2022 走看看