Console logs recording

PostHog can capture console logs, info, warnings, and errors from your application. This is useful for debugging and providing extra context on what is happening in your user's browser or mobile device environment.

Console log capture is on by default for new projects. Console logs can contain sensitive information, so review what your app logs before you leave this on. You can turn it on or off in your project settings. To control it client-side, set enable_recording_console_log in the JavaScript Web SDK config.

Web
posthog.init('<ph_project_token>', {
api_host: 'https://us.i.posthog.com',
defaults: '2026-08-30',
enable_recording_console_log: true,
// ... other options
})

Important: Individual console logs are truncated at 2000 characters. The rest of the log is not sent to PostHog. When truncating a log message we add ...[Truncated] to the message.

Viewing and searching console logs

Once enabled, you can then view captured console logs by clicking the "Inspector" button and choosing the console tab.

Logs in session replay

In that tab, you can search for specific logs with the following patterns:

TokenMatch TypeDescription
jscriptfuzzy-matchItems that fuzzy match jscript
=schemeexact-matchItems that are scheme
'pythoninclude-matchItems that include python
!rubyinverse-exact-matchItems that do not include ruby
^javaprefix-exact-matchItems that start with java
!^earlanginverse-prefix-exact-matchItems that do not start with earlang
.js$suffix-exact-matchItems that end with .js
!.go$inverse-suffix-exact-matchItems that do not end with .go

Still have questions?

Was this page useful?