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)?
I’m attempting to do the same thing, to get better logging to find the root of an error, and copied and pasted the code you provided into ./config/middleware.js, and the log level stays the same in the terminal, as “debug”. Running strapi with npm run develop.
Overriding the logger middleware setting the way @DMehaffy explained is working. You can validate this by changing it to info for example and you should see that nothing higher than info will be printed out.
That being said, your use case is exactly the opposite, you want a more verbose output. But setting the log level to TRACE won’t really help, since it seems that nothing is logged with this level of verbosity. I personally solved my issue by debugging ans inspecting, maybe that could be the way to go for you as well.
In the meantime, I am curious to know what would be the ideal approach to get a more verbose output than debug@DMehaffy?
Interesting, I did as you suggested, and when changing it to info, I get no output for REST ops, but there appears to be no difference in the level of verbosity or information between debug and trace that I can see so far. I agree that having to put in place your own debugger seems the route to go.
There is another way of making this work. Export your middleware.js with the env object and pass it a default. This way you can make sure your process.env will override it: