How to change log directory location in postgresql 9.4?

17,150

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]
Share:
17,150
John doe
Author by

John doe

Beginner to coding. Interested in learning java. Some times my questions might be silly but i'm trying very hard to learn java coding

Updated on June 05, 2022

Comments

  • John doe
    John doe almost 2 years

    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'
    
    • jdabrowski
      jdabrowski about 8 years
      Please add error logs, probably postgres user does not have sufficient privileges to acces new log directory.
    • John doe
      John doe about 8 years
      This is after i changed the log path 2016-03-09 16:41:43 EST FATAL: could not open log file "/logs/demo/postgresql-2016-03-09_164143.log": Permission denied
  • John doe
    John doe about 8 years
    Thanks a lot. It worked. Can you please tell How to enable tcp/ip connections to connect from pgadmin to the server? Please bear with me i'm a beginner.
  • John doe
    John doe about 8 years
    Thanks a lot @jdabrowski. Made my job a lot easier. Should it be 0.0.0.0/32 or 0.0.0.0/0?
  • jdabrowski
    jdabrowski about 8 years
    Depends on what you want to achieve, if you want to allow everything you can use 0 at the end :)
  • John doe
    John doe about 8 years
    Thank you but even after i made changes in the pg_hba.conf.. Im still not able to connect to the database using pgadmin. It still says connection refused
  • jdabrowski
    jdabrowski about 8 years
    Maybe you're using wrong port to connect? The default is 5432, but maybe you've changed it in postgresql.conf file?
  • jdabrowski
    jdabrowski about 8 years
    Also in postgresql.conf file you need to set listen_addresses = '*'.
  • jdabrowski
    jdabrowski about 8 years
    You have to check the connection then, make sure so firewall blocks it, etc.
  • John doe
    John doe about 8 years
    Yes, the firewall's blocking it. Thanks a lot.