Debug Realtime with Logger and Log Levels
Last edited: 12/12/2025
What are logger and log_level parameters?
The Realtime client provides built-in logging to help you debug connection issues, track messages, and understand what's happening with your real-time connections. Two parameters control logging:
logger: A custom function to handle log messageslogLevel: Controls which messages the server logs (info,warn, orerror)
By default, logging is disabled. When enabled, you can see:
- Messages sent and received
- Connection events (connect, disconnect, errors)
- Heartbeat status
- Channel subscriptions
- Worker events
How to enable logging in your Realtime client
Basic logging to console
1import { createClient } from '@supabase/supabase-js'23const supabase = createClient(SUPABASE_URL, SUPABASE_KEY, {4 realtime: {5 logger: (kind, msg, data) => {6 console.log(`${kind}: ${msg}`, data)7 },8 },9})With log levels for server-side filtering
1const supabase = createClient(SUPABASE_URL, SUPABASE_KEY, {2 realtime: {3 logLevel: 'info', // 'info' | 'warn' | 'error'4 logger: (kind, msg, data) => {5 console.log(`[${kind}] ${msg}`, data)6 },7 },8})Understanding log messages
The logger receives three parameters: kind, msg, and data.
Log kinds you'll see:
push - Messages sent to the server
1push: realtime:chat heartbeat (42) {}2push: realtime:chat phx_join (1) { config: {...} }receive - Messages received from server
1receive: ok realtime:chat phx_reply (1) { response: {...} }2receive: realtime:chat broadcast { event: 'message', payload: {...} }transport - Connection events
1transport: connected to wss://project.supabase.co/realtime/v12transport: heartbeat timeout. Attempting to re-establish connection3transport: close CloseEvent {...}4transport: leaving duplicate topic "realtime:chat"error - Error events
1error: error in heartbeat callback Error: ...2error: error waiting for auth on connect Error: ...worker - Web Worker events
1worker: starting default worker2worker: starting worker for from /worker.js3worker: worker error messageCommon debugging scenarios
Debug why channel won't subscribe:
1import { createClient } from '@supabase/supabase-js'23const supabase = createClient(SUPABASE_URL, SUPABASE_KEY, {4 realtime: {5 logger: (kind, msg, data) => {6 console.log(`[${kind}] ${msg}`, data)7 },8 },9})1011const channel = supabase12 .channel('debug-channel')13 .on('broadcast', { event: 'test' }, (payload) => {14 console.log('Received:', payload)15 })16 .subscribe((status, err) => {17 console.log('Subscribe status:', status, err)18 })1920// Check logs for:21// push: realtime:debug-channel phx_join - subscription attempt22// receive: ok realtime:debug-channel phx_reply - successful subscription23// Or error messages if subscription failedDebug message delivery issues
1const supabase = createClient(SUPABASE_URL, SUPABASE_KEY, {2 realtime: {3 logger: (kind, msg, data) => {4 if (kind === 'push' || kind === 'receive') {5 console.log(`[${kind}] ${msg}`, data)6 }7 },8 },9})1011const channel = supabase.channel('chat', { config: { broadcast: { self: true } } })1213channel.on('broadcast', { event: 'message' }, (payload) => {14 console.log('Message received:', payload)15})16// Send message after subscribing17channel.subscribe((status, err) => {18 if (status == 'SUBSCRIBED') {19 channel.send({20 type: 'broadcast',21 event: 'message',22 payload: { text: 'Hello' },23 })24 } else {25 console.error({ status, err })26 }27})2829// Check logs:30// push: realtime:chat broadcast - message sent31// receive: realtime:chat broadcast - message received (if self: true)