Key*_*ani 5 javascript logging node.js winston
所以我试图将控制台作为传输附加到winston记录器.以下是我的代码.
winston.add(winston.transports.Console, {
level: 'info',
colorize: true,
timestamp: true,
json: false,
stringify: false,
prettyPrint: true,
depth: 5,
humanReadableUnhandledException: true,
showLevel: true,
stderrLevels: ['error', 'debug']
});
Run Code Online (Sandbox Code Playgroud)
但是,当我启动应用程序时,我得到以下错误.
C:\Users\xxxxx\yyyyy\javascript\MyApp\node_modules\winston\lib\winston\logger.js:481
throw new Error('Transport already attached: ' + instance.name + ", assign a different name");
^
Error: Transport already attached: console, assign a different name
at Logger.add (C:\Users\xxxxx\yyyyy\javascript\MyApp\node_modules\winston\lib\winston\logger.js:481:11)
at Object.winston.(anonymous function) [as add] (C:\Users\xxxxx\yyyyy\javascript\MyApp\node_modules\winston\lib\winston.js:87:34)
at Object.<anonymous> (C:\Users\xxxxx\yyyyy\javascript\MyApp\app.js:36:9)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\xxxxx\yyyyy\javascript\MyApp\bin\www:7:11)
Run Code Online (Sandbox Code Playgroud)
现在,我知道我的控制台已默认附加到记录器.但我还在写这个,因为我想根据自己的喜好改变配置.
任何人都可以建议我如何实现这一目标?我是否必须使用其他语法来更改已连接的传输的配置,或者使用与我使用的相同代码有什么方法吗?
请建议.
如果您已经连接了相同类型的传输,则需要为新传输命名:
winston.add(winston.transports.Console, {
name : 'UNIQUE_NAME_HERE',
level: 'info',
...
});
Run Code Online (Sandbox Code Playgroud)
记录在这里.
| 归档时间: |
|
| 查看次数: |
3318 次 |
| 最近记录: |