-
Notifications
You must be signed in to change notification settings - Fork 6
/
README
55 lines (43 loc) · 1.99 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Introduction
============
pg_logforward is a custom logging handler for PostgreSQL. It intercepts
all PostgreSQL log messages by hooking into EmitErrorReport() function
in the backend. The intercepted log messages are forwarded via UDP to
a remote location.
Requires PostgreSQL logging hooks patch - included in the patches directory.
The patch is against 9.2devel but also applies against 9.1 and 8.3. Although
some offsets are expected.
Building
========
USE_PGXS=1 make install
Output formats
==============
The current version supports JSON, netstring and Syslog output formats.
Usage
=====
Modify postgresql.conf to include:
shared_preload_libraries = 'pg_logforward' # requires restart
#custom_variable_classes = 'logforward' # needed for 9.1 and older
logforward.target_names = 'syslog,jsonsrv,netstr'
logforward.syslog_format = 'syslog'
logforward.syslog_host = '127.0.0.1'
logforward.syslog_port = 23456
logforward.syslog_min_elevel = 19 # WARNING and above
logforward.syslog_facility = 'local1'
logforward.jsonsrv_format = 'json'
logforward.jsonsrv_host = '127.0.0.1'
logforward.jsonsrv_port = 23457
logforward.jsonsrv_message_filter = 'connect'
logforward.netstr_format = 'netstr'
logforward.netstr_host = '127.0.0.1'
logforward.netstr_port = 23458
logforward.netstr_message_filter = 'foo|bar|baz' # match any 3
logforward.netstr_funcname_filter = 'exec_simple_query' # filter on the C function
# that calls ereport()
# By default all fields are logged. Setting logforward.*_log_fields enables to
# omit certain fields or change the order of fields.
#logforward.netstr_log_fields = "username, database, remotehost, debug_query_string,
# elevel, funcname, sqlerrcode, message, detail, hint,
# context, instance_label, timestamp"
Note that you need to copy the shared library also to $libdir/plugins if you
are planning to use local_preload_libraries instead of shared_preload_libraries.