Clerk Logging Configuration Guide
This guide covers how to configure CLERK_LOGGING in your Clerk application, both through environment variables and programmatically.
Overview
Clerk logging helps you debug and monitor authentication flows in your application. You can enable different levels of logging to see what's happening under the hood.
Method 1: Using Environment Variables
Setting in .env File
Create or edit your .env.local file (or .env file) in your project root:
CLERK_LOGGING=trueLog Levels
You can specify different log levels:
# Enable all logging
CLERK_LOGGING=true
# Or specify a log level
CLERK_LOGGING=debug
CLERK_LOGGING=info
CLERK_LOGGING=warn
CLERK_LOGGING=errorPlatform-Specific Setup
Next.js
Add to .env.local:
CLERK_LOGGING=trueThe environment variable will be automatically picked up by Clerk.
Node.js/Express
Add to .env:
CLERK_LOGGING=trueMethod 2: Programmatic Configuration
Next.js (App Router)
export default function MyApp({ Component, pageProps }: AppProps) {
return (
<ClerkProvider
{...pageProps}
debug={true}
telemetry={true}
>
);
}Log Levels Explained
| Level | Description |
|---|---|
debug | Most verbose - shows all logs including internal operations |
info | General informational messages about normal operations |
warn | Warning messages for potentially problematic situations |
error | Only error messages |
Best Practices
Development: Enable debug logging to see detailed information
envCLERK_LOGGING=debugProduction: Disable or use error-level logging only
envCLERK_LOGGING=errorSecurity: Never commit
.envfiles with sensitive keys to version control
Troubleshooting
Logs Not Appearing
Verify the environment variable is loaded:
javascriptconsole.log(process.env.CLERK_LOGGING);Check browser console (frontend) or terminal (backend)
Ensure you've restarted your development server after changing
.envfilesFor Next.js, ensure you're using the correct prefix (
NEXT_PUBLIC_for client-side)
Too Many Logs
Reduce verbosity by changing the log level:
CLERK_LOGGING=warnOr disable completely:
CLERK_LOGGING=false