HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

How to trigger newlines in log messages?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
triggerlognewlinesmessageshow

Problem

Is it possible for log messages to span multiple lines? I am expecting:

RAISE WARNING 'Line 1\nLine 2';

to result in the following log:

Line 1
Line 2


But instead I get:

Line 1\nLine 2

Any ideas?

Solution

It's the same as any other string. Either use non-standard E'' strings to tell PostgreSQL you want escape processing:

RAISE WARNING E'Line 1\nLine 2';


or use SQL-standard strings with literal newlines:

RAISE WARNING 'Line 1
Line 2';

Code Snippets

RAISE WARNING E'Line 1\nLine 2';
RAISE WARNING 'Line 1
Line 2';

Context

StackExchange Database Administrators Q#76931, answer score: 15

Revisions (0)

No revisions yet.