Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 76fa5e6

Browse files
committed
Cause Win32 to output to the event log rather than stderr by default.
Magnus Hagander
1 parent afbc30e commit 76fa5e6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/backend/utils/error/elog.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
*
4444
* IDENTIFICATION
45-
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.156 2005/02/22 04:37:38 momjian Exp $
45+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.157 2005/02/27 01:02:57 momjian Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -1630,7 +1630,18 @@ send_message_to_server_log(ErrorData *edata)
16301630
#endif /* WIN32 */
16311631
/* Write to stderr, if enabled */
16321632
if ((Log_destination & LOG_DESTINATION_STDERR) || whereToSendOutput == Debug)
1633+
{
1634+
#ifdef WIN32
1635+
/* In a win32 service environment, there is no usable stderr. Capture
1636+
anything going there and write it to the eventlog instead.
1637+
If stderr redirection is active, leave it to stderr because the
1638+
logger will capture it to a file. */
1639+
if ((!Redirect_stderr || am_syslogger) && pgwin32_is_service())
1640+
write_eventlog(EVENTLOG_ERROR_TYPE, buf.data);
1641+
else
1642+
#endif
16331643
fprintf(stderr, "%s", buf.data);
1644+
}
16341645

16351646
/* If in the syslogger process, try to write messages direct to file */
16361647
if (am_syslogger)

0 commit comments

Comments
 (0)