Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d5282c

Browse files
committed
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 originalstderr output to try to diagnose problems, not realizing/remembering thattheir 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 loggingconfiguration to something more in line with their platform conventions.In hopes of reducing confusion, emit a LOG message about this at the pointin startup where we are about to switch log output away from the originalstderr, providing a pointer to where to look instead. This message willappear as the last thing in the original stderr output. (We might lateralso try to emit such link messages when logging parameters are changedon-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.
1 parentb52cd9d commit3d5282c

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,17 @@ PostmasterMain(int argc, char *argv[])
11641164
* Log_destination permits. We don't do this until the postmaster is
11651165
* fully launched, since startup failures may as well be reported to
11661166
* stderr.
1167+
*
1168+
* If we are in fact disabling logging to stderr, first emit a log message
1169+
* saying so, to provide a breadcrumb trail for users who may not remember
1170+
* that their logging is configured to go somewhere else.
11671171
*/
1172+
if (!(Log_destination&LOG_DESTINATION_STDERR))
1173+
ereport(LOG,
1174+
(errmsg("ending log output to stderr"),
1175+
errhint("Future log output will go to log destination \"%s\".",
1176+
Log_destination_string)));
1177+
11681178
whereToSendOutput=DestNone;
11691179

11701180
/*

‎src/backend/postmaster/syslogger.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,20 @@ SysLogger_Start(void)
634634
/* now we redirect stderr, if not done already */
635635
if (!redirection_done)
636636
{
637+
#ifdefWIN32
638+
intfd;
639+
#endif
640+
641+
/*
642+
* Leave a breadcrumb trail when redirecting, in case the user
643+
* forgets that redirection is active and looks only at the
644+
* original stderr target file.
645+
*/
646+
ereport(LOG,
647+
(errmsg("redirecting log output to logging collector process"),
648+
errhint("Future log output will appear in directory \"%s\".",
649+
Log_directory)));
650+
637651
#ifndefWIN32
638652
fflush(stdout);
639653
if (dup2(syslogPipe[1],fileno(stdout))<0)
@@ -649,8 +663,6 @@ SysLogger_Start(void)
649663
close(syslogPipe[1]);
650664
syslogPipe[1]=-1;
651665
#else
652-
intfd;
653-
654666
/*
655667
* open the pipe in binary mode and make sure stderr is binary
656668
* after it's been dup'ed into, to avoid disturbing the pipe

‎src/backend/utils/error/elog.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ emit_log_hook_type emit_log_hook = NULL;
109109
intLog_error_verbosity=PGERROR_VERBOSE;
110110
char*Log_line_prefix=NULL;/* format for extra log line info */
111111
intLog_destination=LOG_DESTINATION_STDERR;
112+
char*Log_destination_string=NULL;
112113

113114
#ifdefHAVE_SYSLOG
114115

‎src/backend/utils/misc/guc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,6 @@ inttcp_keepalives_count;
444444
* cases provide the value for SHOW to display. The real state is elsewhere
445445
* and is kept in sync by assign_hooks.
446446
*/
447-
staticchar*log_destination_string;
448-
449447
staticchar*syslog_ident_str;
450448
staticboolphony_autocommit;
451449
staticboolsession_auth_is_superuser;
@@ -2871,7 +2869,7 @@ static struct config_string ConfigureNamesString[] =
28712869
"depending on the platform."),
28722870
GUC_LIST_INPUT
28732871
},
2874-
&log_destination_string,
2872+
&Log_destination_string,
28752873
"stderr",
28762874
check_log_destination,assign_log_destination,NULL
28772875
},

‎src/include/utils/elog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ typedef enum
428428
externintLog_error_verbosity;
429429
externchar*Log_line_prefix;
430430
externintLog_destination;
431+
externchar*Log_destination_string;
431432

432433
/* Log destination bitmap */
433434
#defineLOG_DESTINATION_STDERR 1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp