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 1fxKfQ-0002Bz-3p for pgsql-bugs@arkaria.postgresql.org; Tue, 04 Sep 2018 23:23:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fxKfM-0001tE-M0 for pgsql-bugs@arkaria.postgresql.org; Tue, 04 Sep 2018 23:23:24 +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 1fxKfM-0001t7-Fr for pgsql-bugs@lists.postgresql.org; Tue, 04 Sep 2018 23:23:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fxKfI-0002J9-RK for pgsql-bugs@lists.postgresql.org; Tue, 04 Sep 2018 23:23:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w84NN856007449; Tue, 4 Sep 2018 19:23:09 -0400 From: Tom Lane To: mario@emmenlauer.de cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15363: Logging unexpectedly goes to system event log instead of stderr In-reply-to: <153609661847.23143.7555891587635366496@wrigleys.postgresql.org> References: <153609661847.23143.7555891587635366496@wrigleys.postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Tue, 04 Sep 2018 21:30:18 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7447.1536103388.1@sss.pgh.pa.us> Date: Tue, 04 Sep 2018 19:23:08 -0400 Message-ID: <7448.1536103388@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?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.) regards, tom lane