2
ウィンスストンロガーへのトランスポートとしてコンソールを接続しようとしています。以下は私のコードです。コンソールトランスポートをウィンストンログに添付する
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']
});
しかし、私は、アプリケーションを起動したとき、私はエラーの下に取得します。
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)
ここで、私のコンソールはデフォルトで既にロガーに接続されていることを理解しています。しかし、私は自分の好みに合わせて設定を変更したいので、これを追加して書いています。
どのように私はこれを達成するために提案できますか?すでに接続されているトランスポートのコンフィグレーションを変更するために他の構文を記述する必要がありますか?使用しているコードと同じコードでこれを回避する方法はありますか?
お勧めします。
ありがとうございました。これは助けになりました。 –