Search code examples
strapi

How can I override log level?


I am running Strapi 3.2.5 in development mode (strapi develop).

I would like to change the default log level (debug) to something more verbose (trace) in order to troubleshoot server error I am getting from strapi admin panel (400 response for example).

When overriding the STRAPI_LOG_LEVEL environment variable like mentionned in the doc here, I am getting this message: debug STRAPI_LOG_LEVEL environment variable is overridden by logger middleware. It only applies outside Strapi's middleware context.

What is Strapi’s middleware context? And if the log level is not customizable in my case, what would be the solution to get more details on the reason of the 400 response (without having to breaking into the the source)?


Solution

  • I got the answer on Strapi's community forum here.

    see the middleware documentation for the logger here: https://strapi.io/documentation/v3.x/concepts/middlewares.html#request-middlewares

    You will need to create (or update if the file already exists) the ./config/middleware.js file with the proper log level from here: https://strapi.io/documentation/v3.x/cli/CLI.html#strapi-start

    So something like:

    module.exports = {
     //...
       settings: {
       logger: {
         level: "trace",
       },
     },
     //...
    };