diff -cr postgresql-snapshot-030321/src/backend/utils/error/elog.c postgresql-win32-mha/src/backend/utils/error/elog.c
*** postgresql-snapshot-030321/src/backend/utils/error/elog.c	Fri Mar 19 03:23:59 2004
--- postgresql-win32-mha/src/backend/utils/error/elog.c	Mon Mar 22 23:28:11 2004
***************
*** 71,76 ****
--- 71,77 ----
  PGErrorVerbosity Log_error_verbosity = PGERROR_VERBOSE;
  char       *Log_line_prefix = NULL; /* format for extra log line info */
  
+ #ifndef WIN32
  #ifdef HAVE_SYSLOG
  /*
   * 0 = only stdout/stderr
***************
*** 89,94 ****
--- 90,99 ----
  #define Use_syslog 0
  #endif   /* HAVE_SYSLOG */
  
+ #else /* WIN32 */
+ int Use_syslog = 0;
+ static void write_eventlog(int level, const char *line);
+ #endif
  
  /*
   * ErrorData holds the data accumulated during any one ereport() cycle.
***************
*** 1018,1023 ****
--- 1023,1059 ----
  	}
  }
  #endif   /* HAVE_SYSLOG */
+ #ifdef WIN32
+ /*
+  * Write a message line to the windows event log
+  */
+ static void
+ write_eventlog(int level, const char *line)
+ {
+ 	static HANDLE evtHandle = INVALID_HANDLE_VALUE;
+ 	
+ 	if (Use_syslog == 0)
+ 		return;
+ 
+ 	if (evtHandle == INVALID_HANDLE_VALUE) {
+ 		evtHandle = RegisterEventSource(NULL,"PostgreSQL");
+ 		if (evtHandle == NULL) {
+ 			evtHandle = INVALID_HANDLE_VALUE;
+ 			return;
+ 		}
+ 	}
+ 
+ 	ReportEvent(evtHandle,
+ 				level,
+ 				0,
+ 				0, /* All events are Id 0 */
+ 				NULL,
+ 				1,
+ 				0,
+ 				&line,
+ 				NULL);
+ }
+ #endif /* WIN32*/
  
  /*
   * Format tag info for log lines; append to the provided buffer.
***************
*** 1289,1295 ****
  		write_syslog(syslog_level, buf.data);
  	}
  #endif   /* HAVE_SYSLOG */
! 
  	/* Write to stderr, if enabled */
  	if (Use_syslog <= 1 || whereToSendOutput == Debug)
  	{
--- 1325,1360 ----
  		write_syslog(syslog_level, buf.data);
  	}
  #endif   /* HAVE_SYSLOG */
! #ifdef WIN32
! 	if (Use_syslog >= 1)
! 	{
! 		int eventlog_level;
! 		switch (edata->elevel) 
! 		{
! 			case DEBUG5:
! 			case DEBUG4:
! 			case DEBUG3:
! 			case DEBUG2:
! 			case DEBUG1:
! 			case LOG:
! 			case COMMERROR:
! 			case INFO:
! 			case NOTICE:
! 				eventlog_level = EVENTLOG_INFORMATION_TYPE;
! 				break;
! 			case WARNING:
! 				eventlog_level = EVENTLOG_WARNING_TYPE;
! 				break;
! 			case ERROR:
! 			case FATAL:
! 			case PANIC:
! 			default:
! 				eventlog_level = EVENTLOG_ERROR_TYPE;
! 				break;
! 		}
! 		write_eventlog(eventlog_level, buf.data);
! 	}
! #endif   /* WIN32 */
  	/* Write to stderr, if enabled */
  	if (Use_syslog <= 1 || whereToSendOutput == Debug)
  	{
diff -cr postgresql-snapshot-030321/src/backend/utils/misc/guc.c postgresql-win32-mha/src/backend/utils/misc/guc.c
*** postgresql-snapshot-030321/src/backend/utils/misc/guc.c	Mon Mar 15 16:56:24 2004
--- postgresql-win32-mha/src/backend/utils/misc/guc.c	Mon Mar 22 23:21:38 2004
***************
*** 941,947 ****
  		1000, 0, INT_MAX, NULL, NULL
  	},
  
! #ifdef HAVE_SYSLOG
  	{
  		{"syslog", PGC_SIGHUP, LOGGING_SYSLOG,
  			gettext_noop("Uses syslog for logging."),
--- 941,947 ----
  		1000, 0, INT_MAX, NULL, NULL
  	},
  
! #if defined(HAVE_SYSLOG) || defined(WIN32)
  	{
  		{"syslog", PGC_SIGHUP, LOGGING_SYSLOG,
  			gettext_noop("Uses syslog for logging."),
diff -cr postgresql-snapshot-030321/src/include/utils/elog.h postgresql-win32-mha/src/include/utils/elog.h
*** postgresql-snapshot-030321/src/include/utils/elog.h	Mon Mar 15 16:56:28 2004
--- postgresql-win32-mha/src/include/utils/elog.h	Mon Mar 22 23:22:27 2004
***************
*** 171,177 ****
  extern PGErrorVerbosity Log_error_verbosity;
  extern char *Log_line_prefix;
  
! #ifdef HAVE_SYSLOG
  extern int	Use_syslog;
  #endif
  
--- 171,177 ----
  extern PGErrorVerbosity Log_error_verbosity;
  extern char *Log_line_prefix;
  
! #if defined(HAVE_SYSLOG) || defined(WIN32)
  extern int	Use_syslog;
  #endif
  
