Parameter · Reporting and Logging / What to Log
log_parameter_max_length_on_error
Sets the maximum length in bytes of data logged for bind parameter values when logging statements, on error. -1 means log values in full.
- Default:
0 - Type: integer (B)
- Range: -1 … 1024MB
- Applies: Session (any user)
In plain words
When a statement with parameters fails, PostgreSQL can show the parameter values in the error's CONTEXT line, which makes the error much easier to reproduce. By default (0) it does not; set a byte limit, or -1 for full values, to turn it on.
For DBAs and operators
Captured on 18.6 with value 10:
ERROR: invalid input syntax for type integer: "notanumberatallreally" CONTEXT: unnamed portal parameter $1 = 'notanumber...' ERROR: division by zero CONTEXT: unnamed portal with parameters: $1 = '0'With the default 0, a value that fails conversion during Bind still gets a CONTEXT line, but the value is hidden: CONTEXT: unnamed portal parameter $1 = '...'; errors raised later, during execution, get no parameter CONTEXT at all (verified on 18.6). The CONTEXT line goes to both the server log and the client. Default 0 because collecting the values costs a little CPU on every bind (the values must be saved in case an error happens later) and because errors may otherwise leak data. Any user can set it in their session, unlike log_parameter_max_length.
Support tip: when a customer reports an intermittent "invalid input syntax" or constraint error from an application, enabling this for the application role (ALTER ROLE app SET log_parameter_max_length_on_error = 256) usually reveals the offending value immediately. Note that log_error_verbosity = terse hides CONTEXT lines.
How to change it
Any user can change it for their session with SET.
See it in context
Related parameters
log_parameter_max_length log_min_error_statement log_error_verbosity