Console logs recording

Last updated:

|Edit this page

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 environment.

As console logs can contain sensitive information, we do not capture these logs automatically. You can enable this feature globally either from your project settings or client-side by setting enable_recording_console_log: true in our JavaScript Web SDK config.

Web
posthog.init('<ph_project_api_key>', {
api_host: https://us.i.posthog.com,
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

Questions?

Was this page useful?

Next article

Canvas recording

PostHog can capture canvas elements from your application. It works in both 2D and WebGL environments. As canvas elements can contain sensitive information and there is no way to mask canvas elements right now , we do not capture these automatically. Once you are sure they are free of PII, you can enable this feature globally from your replay settings . Canvas elements are recorded at a rate of 4 frames per second which may lead to some perceptual differences during playback.

Read next article