Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fxSWl-0001yC-QF for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Sep 2018 07:47:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fxSWi-00077M-Hn for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Sep 2018 07:47:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fxSWi-00077F-Bv for pgsql-bugs@lists.postgresql.org; Wed, 05 Sep 2018 07:47:00 +0000 Received: from aldebaran.he1ix.org ([2a01:4f8:173:803:0:a1de:ba:a]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fxSWf-0005HX-49 for pgsql-bugs@lists.postgresql.org; Wed, 05 Sep 2018 07:46:59 +0000 Received: from host-88-217-174-106.customer.m-online.net ([88.217.174.106] helo=[192.168.33.170]) by aldebaran.he1ix.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fxSWa-0003ik-PM; Wed, 05 Sep 2018 09:46:53 +0200 To: Tom Lane Cc: pgsql-bugs@lists.postgresql.org References: <153609661847.23143.7555891587635366496@wrigleys.postgresql.org> <7448.1536103388@sss.pgh.pa.us> From: Mario Emmenlauer Message-ID: Date: Wed, 5 Sep 2018 09:46:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <7448.1536103388@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 88.217.174.106 X-SA-Exim-Mail-From: mario@emmenlauer.de X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on aldebaran.he1ix.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham version=3.3.1 Subject: Re: BUG #15363: Logging unexpectedly goes to system event log instead of stderr X-SA-Exim-Version: 4.2.1 (built Sun, 08 Nov 2009 07:31:22 +0000) X-SA-Exim-Scanned: Yes (on aldebaran.he1ix.org) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Dear Tom and all, On 05.09.2018 01:23, Tom Lane wrote: > =?utf-8?q?PG_Bug_reporting_form?= writes: >> My question is not about the failed startup, but about the logging. I am >> confused why the permission problem was logged to Windows system log instead >> to stdout/stderr? My postgresql.conf is the default from initdb.exe and >> contains only the default #log_destination = 'stderr'. The documentation at >> https://www.postgresql.org/docs/current/static/runtime-config-logging.html >> says "The default is to log to stderr only". > > elog.c interprets "write to stderr" like this: > > #ifdef WIN32 > > /* > * In a win32 service environment, there is no usable stderr. Capture > * anything going there and write it to the eventlog instead. > * > * If stderr redirection is active, it was OK to write to stderr above > * because that's really a pipe to the syslogger process. > */ > else if (pgwin32_is_service()) > write_eventlog(edata->elevel, buf.data, buf.len); > #endif > else > write_console(buf.data, buf.len); > > I imagine that pgwin32_is_service was yielding true in your situation. > Unfortunately, I don't know if there's much we can do about this; > as I recall, there's no good way for us to discover whether stderr > output goes anywhere useful. > > (Hmm, looking at the code, it could also be that pgwin32_is_service > was reporting failure. I'm not sure whether it's a great idea that > we're effectively assuming we're a service when we can't really > tell.) Aaah! Yes things make sense now, looking at elog.c! Thanks. But just to ask, is it so fatal for a service to print to console? I recall from Windows XP that there was a buffer of several hundred KB that could be filled before it eventually killed the application. In case of my specific problem, it would have been really helpful if either: - a message on console would have pointed to the log redirection, or - the fatal error (before program termination) would have been printed on console, possibly in addition to the event log. Would any of this make any sense to you? All the best and thanks again, Mario Emmenlauer -- BioDataAnalysis GmbH, Mario Emmenlauer Tel. Buero: +49-89-74677203 Balanstr. 43 mailto: memmenlauer * biodataanalysis.de D-81669 München http://www.biodataanalysis.de/