Index: utils/error/elog.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/error/elog.c,v
retrieving revision 1.155
diff -c -r1.155 elog.c
*** utils/error/elog.c	31 Dec 2004 22:01:27 -0000	1.155
--- utils/error/elog.c	20 Feb 2005 19:05:52 -0000
***************
*** 1630,1636 ****
--- 1630,1647 ----
  #endif   /* WIN32 */
  	/* Write to stderr, if enabled */
  	if ((Log_destination & LOG_DESTINATION_STDERR) || whereToSendOutput == Debug)
+ 	{
+ #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, leave it to stderr because the
+ 		   logger will capture it to a file. */
+ 		if ((!Redirect_stderr || am_syslogger) && pgwin32_is_service())
+ 			write_eventlog(EVENTLOG_ERROR_TYPE, buf.data);
+ 		else
+ #endif
  		fprintf(stderr, "%s", buf.data);
+ 	}

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