Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddidb-0004Wv-8B for pgsql-admin@arkaria.postgresql.org; Fri, 04 Aug 2017 19:51:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ddida-0001HB-Nf for pgsql-admin@arkaria.postgresql.org; Fri, 04 Aug 2017 19:51:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ddibg-0004nT-Vz for pgsql-admin@postgresql.org; Fri, 04 Aug 2017 19:50:01 +0000 Received: from leghorn.comp.uvic.ca ([142.104.42.108]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ddibb-0005xa-15 for pgsql-admin@postgresql.org; Fri, 04 Aug 2017 19:49:57 +0000 Received: from [192.168.1.4] (S01060018f8676393.gv.shawcable.net [184.66.128.136]) (authenticated bits=0) by leghorn.comp.uvic.ca (8.14.4/8.14.4) with ESMTP id v74JnWOB011166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 4 Aug 2017 12:49:33 -0700 Subject: Re: Logging: stderr vs syslog? To: pgsql-admin@postgresql.org References: From: Evan Rempel Message-ID: Date: Fri, 4 Aug 2017 12:49:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------7C375758951F26BB2AC306CD" Content-Language: en-MW X-UVic-Virus-Scanned: OK - Passed virus scan by ClamAV (clamd) on leghorn X-UVic-Virus-Scanned: OK - Passed virus scan by Sophos (sophie) on leghorn X-UVic-Scan: leghorn.comp.uvic.ca filter_version 3.7.9 X-UVic-Outbound-Scan: leghorn.comp.uvic.ca Not_scanned_Remote X-UVic-Spam-Scan: leghorn.comp.uvic.ca No_recips_rejected X-UVic-Spam-Status: No X-UVic-Spam-Score: 0.251 HELO_MISC_IP,HTML_MESSAGE X-UVic-Spam-Level: Spam-Level X-Scanned-By: MIMEDefang 2.78 List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org This is a multi-part message in MIME format. --------------7C375758951F26BB2AC306CD Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit I have been a systems administrator of PostgreSQL since version 7.0. I am also a primary logging architect for a 4000+ device network infrastructure and SEIM alerting infrastructure architect. Syslog is by far the best approach to logging. With the right product it is way FASTER than stderr and there are a ton of tools to parse, analyze, view and report on syslog streams. There is one caveat with PostgreSQL version <= 9.5 and that is that syslog messages are wrapped at approx 80 characters which makes parsing and error detection problematic. pgBadger may address this limitation by unwrapping such logs messages whereas generic log parsing engines do not have any specialized knowledge about how PostgreSQL lines might be wrapped. PostgreSQL version <= 9.5 this is a compile time only option but starting in 9.6 this is a runtime configuration directive. There are two strong reasons for using syslog. 1. In a well architected logging solution the syslog process on the host will also send the log messages to a central log server. This means that if the database server is compromised leading to an untrusted set of log files, there is a trusted copy of the logs on another server. 2. When running a high availability or clustered database all of the logs can be aggregated to a central log server which places all of the logs from all of the database servers into one easy to read/parse/process location. I hope this provides some rationale for using syslog. Evan. On 08/04/2017 09:26 AM, Don Seiler wrote: > I've just inherited a few PostgreSQL DBs, having come from Oracle > land. I'm looking to shore up the logging situation. Right now we use > stderr logging and they get rotated based on size threshold. I'd like > for those old logs to be gzipped so we can keep more on disk rather > than current method of just deleting old logs to free up space. This > is mostly on pgsql 9.2 with a couple of 9.3, but I'm planning to > upgrade everything to 9.6.3 when I get my feet on solid ground. > > Couple of question around this: > > 1. I thought logrotate would be a no-brainer here, but it sounds like > I should then change to use syslog rather than stderr. I've read > some caveats around syslog needing to sync files and potentially > slow things down. I'm wondering if any grizzled production > postgres veterans could offer up their experience. > 2. Alternatively I could just keep it going with stderr and have a > separate script run find/gzip on log files beyond a certain mtime > threshold. This would probably be the quickest to implement, but > I'd much rather use logrotate facilities if there are no strong > opinions against using syslog. > > Thanks in advance for your time, I'm sure I'll be making a lot of us > of these mailing lists in the not-too-distant future. > > Don. > > -- > Don Seiler > www.seiler.us --------------7C375758951F26BB2AC306CD Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit
I have been a systems administrator of PostgreSQL since version 7.0. I am also a primary logging architect for a 4000+ device network infrastructure and SEIM alerting infrastructure architect.

Syslog is by far the best approach to logging. With the right product it is way FASTER than stderr and there are a ton of tools to parse, analyze, view and report on syslog streams.

There is one caveat with PostgreSQL version <= 9.5 and that is that syslog messages are wrapped at approx 80 characters which makes parsing and error detection problematic. pgBadger may address this limitation by unwrapping such logs messages whereas generic log parsing engines do not have any specialized knowledge about how PostgreSQL lines might be wrapped. PostgreSQL version <= 9.5 this is a compile time only option but starting in 9.6 this is a runtime configuration directive.

There are two strong reasons for using syslog.

1. In a well architected logging solution the syslog process on the host will also send the log messages to a central log server. This means that if the database server is compromised leading to an untrusted set of log files, there is a trusted copy of the logs on another server.

2. When running a high availability or clustered database all of the logs can be aggregated to a central log server which places all of the logs from all of the database servers into one easy to read/parse/process location.

I hope this provides some rationale for using syslog.

Evan.

On 08/04/2017 09:26 AM, Don Seiler wrote:
I've just inherited a few PostgreSQL DBs, having come from Oracle land. I'm looking to shore up the logging situation. Right now we use stderr logging and they get rotated based on size threshold. I'd like for those old logs to be gzipped so we can keep more on disk rather than current method of just deleting old logs to free up space. This is mostly on pgsql 9.2 with a couple of 9.3, but I'm planning to upgrade everything to 9.6.3 when I get my feet on solid ground.

Couple of question around this:
  1. I thought logrotate would be a no-brainer here, but it sounds like I should then change to use syslog rather than stderr. I've read some caveats around syslog needing to sync files and potentially slow things down. I'm wondering if any grizzled production postgres veterans could offer up their experience.
  2. Alternatively I could just keep it going with stderr and have a separate script run find/gzip on log files beyond a certain mtime threshold. This would probably be the quickest to implement, but I'd much rather use logrotate facilities if there are no strong opinions against using syslog.
Thanks in advance for your time, I'm sure I'll be making a lot of us of these mailing lists in the not-too-distant future.

Don.

--
Don Seiler
www.seiler.us


--------------7C375758951F26BB2AC306CD--