John doe
John doe

Reputation: 33

How to change log directory location in postgresql 9.4?

my current log_directory path is

**/opt/demo/PostgreSQL/9.4/data/pg_log**

I'm trying to change the log directory path to

**/logs/demo/**

The server won't start when i uncomment the log path and it starts only when its default.

The postgresql.conf file looks like

# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------

# - Where to Log -

log_destination = 'stderr'         # Valid values are combinations of
                                  # stderr, csvlog, syslog, and eventlog,
# This is used when logging to stderr:
logging_collector = on
# These are only used if logging_collector is on:
#log_directory = '/logs/etbos/demo/'  #directorywherelogfiles are written
#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'  # log file name pattern,


# These are relevant when logging to syslog:
#syslog_facility = 'LOCAL0'
#syslog_ident = 'postgres'

# This is only relevant when logging to eventlog (win32):
#event_source = 'PostgreSQL'

Upvotes: 3

Views: 19622

Answers (1)

jdabrowski
jdabrowski

Reputation: 1975

So this is what I supposed :) You need to grant permissions to the new log directory to postgres user.

You can do this using f.e.:

sudo chown postgres:postgres /your/new/log/dir/path

Answering your other question:

To allow TCP/IP connections from remote hosts you need to edit pg_hba.conf file. You can allow ALL TCP/IP connections by adding a line like this:

host  all  all   0.0.0.0/32  md5

There are five parameters above, you can read about them in the pg_hba.conf file in the comments at the top of the file, but in short they mean:

[connection_type] [database_name] [user_name] [remote_ip/mask] [auth_type]

Upvotes: 3

Related Questions