Strapi自定义记录器配置



我有一个Strapi v4应用程序,包含以下内容:

/config/logger.js

'use strict';
const {
winston,
formats: { prettyPrint, levelFilter },
} = require('@strapi/logger');
module.exports = {
transports: [
new winston.transports.Console({
level: 'debug',
format: winston.format.combine(
levelFilter('debug'),
prettyPrint({ timestamps: 'YYYY-MM-DD hh:mm:ss.SSS' })
),
}),
],
};

此外,在我的中/config/functions/bootstrap.js我得到了以下代码

'use strict';
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*/
module.exports = () => {
console.log("Hello World!");
logger.log("debug","Hello Strapi app!");
};

不幸的是,我在我的文件夹Strapi应用程序或网络浏览器中没有看到它打印在任何地方。有什么能帮我的主意吗?

问候

您需要在中间件配置文件中配置记录器,请参阅https://docs.strapi.io/dev-docs/configurations/middlewares#logger

最新更新