Skip to main content

服务器日志级别为 http

¥Server log level is http

你可以在配置中调整服务器日志级别,以控制在服务器日志中看到的详细信息量。如果你想在服务器日志中看到更多或更少的详细日志,此功能允许你根据需要对其进行自定义。

¥You can adjust the server log level in the configuration to control how much detail you see in your server logs. If you want to see more or less verbose logs in your server logs, this feature allows you to customize it according to your needs.

此页面是 重大变更数据库 的一部分,提供有关重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的其他说明。

¥This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

\🔌 此重大更改是否会影响插件?\
\🤖 此重大更改是否由 codemod 自动处理?\

重大更改描述

¥Breaking change description

在 Strapi v4 中

¥In Strapi v4

日志级别默认为 silly,这意味着显示每个日志,提供最详细的信息。

¥The log level defaults to silly, which means that every log is shown, providing the most detailed information.

在 Strapi 5 中

¥In Strapi 5

日志级别默认为 http。这意味着 sillydebug 级别日志默认是隐藏的,从而提供不太详细的日志输出。

¥The log level defaults to http. This means that sillyand debug level logs are hidden by default, offering a less verbose log output.

迁移

¥Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

¥This section regroups useful notes and procedures about the introduced breaking change.

注意

¥Notes

日志级别可以在 server.js 文件中配置,如以下手动迁移部分所述,也可以按照 中间件配置 文档中的说明进行配置。

¥The log level can be configured either in the server.js file as described in the following Manual migration section, or as described in the middlewares configuration documentation.

查看 Winston 日志级别列表

¥See the list of Winston log levels.

手动迁移

¥Manual migration

要迁移到 Strapi 5:

¥To migrate to Strapi 5:

  1. 打开你的服务器配置文件 (config/server)。

    ¥Open your server configuration file (config/server).

  2. 找到 { logger: { config: { level: 'debug' } } 部分。

    ¥Locate the { logger: { config: { level: 'debug' } } section.

  3. 将级别值修改为你喜欢的日志级别,例如 sillydebuginfowarnerror

    ¥Modify the level value to your preferred log level, such as silly, debug, info, warn, or error.