Log Level Enforcement in Nuxt 3
The log.level configuration in nuxt.config.ts does not strictly enforce output limits across all internal Nuxt modules or third-party plugins. While it controls the application-level logger, it does not act as a global interceptor for all console output generated during the build or runtime phases.
Why Modules Bypass Global Log Levels
The discrepancy occurs because Nuxt 3 separates logging across different layers of its architecture. The likely reasons for persistent noise include:
- Direct Console Usage: Many third-party modules use
console.log, console.warn, or console.error directly. These bypass the Nuxt logger entirely and are printed to the stdout of the process.
- Build-time vs. Runtime: The
log.level setting primarily affects the runtime environment. Build-time output is controlled by the Nuxt CLI and the underlying Nitro engine, which operate on different configuration paths.
- Nitro Independence: Nitro (the server engine) has its own logging mechanism. If a module is performing server-side operations, it may be adhering to Nitro's internal defaults rather than the Nuxt application config.
Steps to Suppress Module Output
Since there is no single documented method to force all third-party modules to adhere to the global log.level, you must target the specific layer producing the noise:
- For Nitro Server Logs: Use the
NITRO_LOG_LEVEL environment variable in your .env file to filter server-side output.
NITRO_LOG_LEVEL=error
- For Build-time Noise: If you are seeing excessive debug info during
npm run dev or build, ensure you are not running with the DEBUG environment variable active (e.g., DEBUG=nuxt:*), as this overrides most restrictive settings.
- For Persistent Third-Party Warnings: If a specific module uses
console.warn, the only resolution is typically to check if that module provides its own debug or silent option within its configuration block in nuxt.config.ts.
Verification
To verify which layer is producing the logs, run your application with a clean environment and check if the logs persist across both npm run dev (build/dev) and npm run build && npm run preview (production/nitro). If logs only appear during the build, they are CLI-driven; if they appear during preview, they are Nitro-driven.
Diagnostic Detail Needed: Are the unwanted logs appearing during the build/compilation phase or during the runtime/server execution?