問題タブ [winston]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
node.js - node.js Winston - ロガーを安全に排出する方法
https://github.com/flatiron/winston#instantiating-your-own-loggerで(半分) 説明されているように、winston ロガーのインスタンス化とクローズを試しましたが、役に立ちませんでした。Winston のファイル トランスポートを閉じる際に問題が発生しました。そのソース コードを調べてみると、ロガーを閉じる適切な方法がそのclose
方法のように思われます。これにより、ロガーが使用するトランスポート ファイルを閉じることができると期待していましたが、そうではないことが判明しました。
node.js サーバーの負荷によって頻度が異なりますが、winston は、close
メソッドが呼び出されてから無限に長い間、それらへの新しい書き込みが開始されなくなってからも無限に長い間、まだ多くのトランスポート ファイルを保持していました。node.js プロセス ファイル記述子テーブル ( lsof -p
) で確認しました。が Winston ロガーに対して呼び出されたとしてもclose
、ログ ファイルのファイル記述子を無期限に「使用中」のままにします。つまり、ログ ファイルが実際に閉じられることはありません。したがって、ファイル記述子がリークし、アプリケーションが長時間稼働した後、最終的に node.js プロセスが ulimit (-n) 制限にぶつかります。
最終的に閉じることができるように Winston ロガーを排出するための特定のプログラミング パターンが必要ですか?
node.js - generic Error handler MEANJS, mongoose, winston
so I've recently started programing in node and MEAN and while working with JAVA I would always focus on best pattern to create solid apps, and even though the learning curve is killing me I'm trying the same here. Anyway I'm trying to implement a generic error handler using MEANjs to have an exception handler in a central place, log errors to a file and send email when this happens.
starting with mongoose for example
this is the handler in express.js :
so here is where it gets confusing since I'm trying to implemente a middleware with express I'm not sure if app.use is the best aproach, I've read that sometimes is not the best aproach, or this is just for Express 3.xx?? what about express 4? below is what I'm using for the logger file and then using it before the express error handler is this good practice or it should go inside the handler?
So landing this. is there a way to have a general errors handler via express 4 using MEANJS sending emails when they happen logging into a file. and get rid of all this repetitive mongoose errors handling keeping in mind best practices for MEANJS.
node.js - NodeJs WinstonJS 非常に奇妙なスタート
NodeJS アプリのログ記録に winstonJS を使い始めました。
私のコードは次のようになります:
コンソールに表示される唯一のログは次のとおりです。
間違った順序にも注意してください。
明らかな何かが欠けていますか?
ありがとう
node.js - Mongoose Docs を使用した Winston Logging
最近、ロギングのために Winston に切り替えたところ、exec の後に mongoose ドキュメントをロギングする際の問題に気付きました。
例:
では、基本的に、console.log から取得したのと同じ方法で winston のログを出力するにはどうすればよいでしょうか? toJSON() を呼び出してログに記録する前に、シリアル化する方法が必要だと思います。
毎回手動で .toJSON() を呼び出す必要がありますか、またはこれを自動的に機能させるために何か他のことをする必要がありますか?
node.js - Winston を使用した複数のファイル転送
Winston で複数のトランスポートを使用しようとしています。これは機能しています...ちょっと。カスタム レベルの「監査」と「情報」のトランスポートを使用して、アプリの監査ログ用にトランスポートをセットアップしました。
明らかに、ログを記録したい場所/ときにこのファイルが必要です。特定の情報をログに個別に送信したい場合に問題が発生します。
これらの 2 行は、別々のログに書き込まれます。最初の行は、データベースと情報ログ ファイルに適切に書き込まれます。私は何を間違っていますか?
node.js - ストリーム モードで Nodejs Winston 日次トランスポートを使用してトランスポート ファイルにタイムスタンプを追加します。
高い並行性でトランスポート ファイルのログが失われるのを修正するために、モードをストリームに変更しました。その後、ログが失われる問題が修正されました。しかし、トランスポートファイルを毎日作成できないという別の問題があります(トランスポートモードをに設定してもDailyRotateFile
)。
このケースを実装するために設定できるオプションはありますか? または私はそれをハックする必要がありますか?
みんなありがとう。
以下のデモコード: