Thread: Separate log for a specfic database

Separate log for a specfic database

From
Ertan Küçükoğlu
Date:
Hello,

I am using PostgreSQL 9.6.6 on Debian 9 Stretch system. Installed using
apt-get.
I wonder if I can have two log files. One for complete database server and
another for one specific database in the server.
I have already read below link, but cannot understand if that is possible,
or how.
https://www.postgresql.org/docs/9.6/static/runtime-config-logging.html

I appreciate any help.

Regards,
Ertan Küçükoğlu





Re: Separate log for a specfic database

From
"David G. Johnston"
Date:
On Wednesday, February 28, 2018, Ertan Küçükoğlu <ertan.kucukoglu@1nar.com.tr> wrote:
Hello,

I am using PostgreSQL 9.6.6 on Debian 9 Stretch system. Installed using
apt-get.
I wonder if I can have two log files. One for complete database server and
another for one specific database in the server.
I have already read below link, but cannot understand if that is possible,
or how.
https://www.postgresql.org/docs/9.6/static/runtime-config-logging.html


When it says:

This parameter can only be set in the postgresql.conf file or on the server command line. "

It is scoped to the cluster and all databases therein.  To do what you desire you would need to put the unique database into its own cluster.

David J.

Re: Separate log for a specfic database

From
Evan Rempel
Date:
On 02/28/2018 10:05 AM, David G. Johnston wrote:
> On Wednesday, February 28, 2018, Ertan Küçükoğlu 
> <ertan.kucukoglu@1nar.com.tr <mailto:ertan.kucukoglu@1nar.com.tr>> wrote:
>
>     Hello,
>
>     I am using PostgreSQL 9.6.6 on Debian 9 Stretch system. Installed
>     using
>     apt-get.
>     I wonder if I can have two log files. One for complete database
>     server and
>     another for one specific database in the server.
>     I have already read below link, but cannot understand if that is
>     possible,
>     or how.
>     https://www.postgresql.org/docs/9.6/static/runtime-config-logging.html
>     <https://www.postgresql.org/docs/9.6/static/runtime-config-logging.html>
>
>
> When it says:
>
> " This parameter can only be set in the postgresql.conf file or on the 
> server command line. "
>
> It is scoped to the cluster and all databases therein.  To do what you 
> desire you would need to put the unique database into its own cluster.
>
> David J.

That is not exactly true.

Logging could be set up to use syslog and if the database name is in the 
log lines
then some filtering and routing of hose messages could go into their own 
files.

This would require a mature syslog environment but it is possible.

Evan.



Re: Separate log for a specfic database

From
Keith
Date:


On Wed, Feb 28, 2018 at 12:35 PM, Ertan Küçükoğlu <ertan.kucukoglu@1nar.com.tr> wrote:
Hello,

I am using PostgreSQL 9.6.6 on Debian 9 Stretch system. Installed using
apt-get.
I wonder if I can have two log files. One for complete database server and
another for one specific database in the server.
I have already read below link, but cannot understand if that is possible,
or how.
https://www.postgresql.org/docs/9.6/static/runtime-config-logging.html

I appreciate any help.

Regards,
Ertan Küçükoğlu





Not sure what you're reasoning may be, but if it's just to be able to do log analysis, there are tools that can do that for you as long as you have the database name in the log_line_prefix. Take a look at pgbadger

http://dalibo.github.io/pgbadger/

Re: Separate log for a specfic database

From
Ibrahim Edib Kokdemir
Date:

We have huge amount of logs files and when using syslog all logs go to journal and journal cannot handle that amount logs. Then we have found nxlog. It is a good solution and double work. Send pg logs as usual and read the read from the file, filter them and either put them into separate files or to another syslog server. Here is the link. Best ever log collector. 

2018-02-28 21:41 GMT+03:00 Keith <keith@keithf4.com>:


On Wed, Feb 28, 2018 at 12:35 PM, Ertan Küçükoğlu <ertan.kucukoglu@1nar.com.tr> wrote:
Hello,

I am using PostgreSQL 9.6.6 on Debian 9 Stretch system. Installed using
apt-get.
I wonder if I can have two log files. One for complete database server and
another for one specific database in the server.
I have already read below link, but cannot understand if that is possible,
or how.
https://www.postgresql.org/docs/9.6/static/runtime-config-logging.html

I appreciate any help.

Regards,
Ertan Küçükoğlu





Not sure what you're reasoning may be, but if it's just to be able to do log analysis, there are tools that can do that for you as long as you have the database name in the log_line_prefix. Take a look at pgbadger

http://dalibo.github.io/pgbadger/