![](/img/trans.png)
[英]winstonjs Get logger created with winston.createLogger(…)
[英]Winston createLogger custom function
在我的節點應用程序中,我使用 winston 進行錯誤記錄。 我想在一個地方創建一個 function 並在 server.js 文件中使用它。 這是我的文件
const exceptionLogger = () => {
createLogger({
exceptionHandlers: [
new transports.File({ filename: 'exceptions.log' }),
],
});
};
但是這個 function 不能稱為exceptionLogger() 。 它使應用程序崩潰。 這是什么原因? 我怎樣才能以正確的方式做到這一點?
你可以試試這個:
export const exceptionLogger = () => {
winston.createLogger({
exceptionHandlers: [
new winston.transports.File({ filename: 'exceptions.log' }),
],
});
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.