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

Commit6d8186f

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 parent7cf5540 commit6d8186f

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
@@ -1183,7 +1183,17 @@ PostmasterMain(int argc, char *argv[])
11831183
* Log_destination permits. We don't do this until the postmaster is
11841184
* fully launched, since startup failures may as well be reported to
11851185
* stderr.
1186+
*
1187+
* If we are in fact disabling logging to stderr, first emit a log message
1188+
* saying so, to provide a breadcrumb trail for users who may not remember
1189+
* that their logging is configured to go somewhere else.
11861190
*/
1191+
if (!(Log_destination&LOG_DESTINATION_STDERR))
1192+
ereport(LOG,
1193+
(errmsg("ending log output to stderr"),
1194+
errhint("Future log output will go to log destination \"%s\".",
1195+
Log_destination_string)));
1196+
11871197
whereToSendOutput=DestNone;
11881198

11891199
/*

‎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
@@ -442,8 +442,6 @@ inttcp_keepalives_count;
442442
* cases provide the value for SHOW to display. The real state is elsewhere
443443
* and is kept in sync by assign_hooks.
444444
*/
445-
staticchar*log_destination_string;
446-
447445
staticchar*syslog_ident_str;
448446
staticboolphony_autocommit;
449447
staticboolsession_auth_is_superuser;
@@ -2833,7 +2831,7 @@ static struct config_string ConfigureNamesString[] =
28332831
"depending on the platform."),
28342832
GUC_LIST_INPUT
28352833
},
2836-
&log_destination_string,
2834+
&Log_destination_string,
28372835
"stderr",
28382836
check_log_destination,assign_log_destination,NULL
28392837
},

‎src/include/utils/elog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ typedef enum
423423
externintLog_error_verbosity;
424424
externchar*Log_line_prefix;
425425
externintLog_destination;
426+
externchar*Log_destination_string;
426427

427428
/* Log destination bitmap */
428429
#defineLOG_DESTINATION_STDERR 1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp