diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-08-13 15:24:52 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-08-13 15:24:52 -0400 |
commit | 3d5282c6f0edbdcb78dd2a6e8068f829fcb2882f (patch) | |
tree | 6e7acae99510ed1c4e4dc8aacb03e6026b1317e4 /src/backend/postmaster/syslogger.c | |
parent | b52cd9d022fee0b653af7e586f2053abaf19f20b (diff) | |
download | postgresql-3d5282c6f0edbdcb78dd2a6e8068f829fcb2882f.tar.gz postgresql-3d5282c6f0edbdcb78dd2a6e8068f829fcb2882f.zip |
Emit a log message if output is about to be redirected away from stderr.
We've seen multiple cases of people looking at the postmaster's original
stderr output to try to diagnose problems, not realizing/remembering that
their logging configuration is set up to send log messages somewhere else.
This seems particularly likely to happen in prepackaged distributions,
since many packagers patch the code to change the factory-standard logging
configuration to something more in line with their platform conventions.
In hopes of reducing confusion, emit a LOG message about this at the point
in startup where we are about to switch log output away from the original
stderr, providing a pointer to where to look instead. This message will
appear as the last thing in the original stderr output. (We might later
also try to emit such link messages when logging parameters are changed
on-the-fly; but that case seems to be both noticeably harder to do nicely,
and much less frequently a problem in practice.)
Per discussion, back-patch to 9.3 but not further.
Diffstat (limited to 'src/backend/postmaster/syslogger.c')
-rw-r--r-- | src/backend/postmaster/syslogger.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c index e3b61025162..8b00aa525b2 100644 --- a/src/backend/postmaster/syslogger.c +++ b/src/backend/postmaster/syslogger.c @@ -634,6 +634,20 @@ SysLogger_Start(void) /* now we redirect stderr, if not done already */ if (!redirection_done) { +#ifdef WIN32 + int fd; +#endif + + /* + * Leave a breadcrumb trail when redirecting, in case the user + * forgets that redirection is active and looks only at the + * original stderr target file. + */ + ereport(LOG, + (errmsg("redirecting log output to logging collector process"), + errhint("Future log output will appear in directory \"%s\".", + Log_directory))); + #ifndef WIN32 fflush(stdout); if (dup2(syslogPipe[1], fileno(stdout)) < 0) @@ -649,8 +663,6 @@ SysLogger_Start(void) close(syslogPipe[1]); syslogPipe[1] = -1; #else - int fd; - /* * open the pipe in binary mode and make sure stderr is binary * after it's been dup'ed into, to avoid disturbing the pipe |