diff -rpcd a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml
*** a/doc/src/sgml/ref/pg_ctl-ref.sgml	Thu May  8 09:17:03 2014
--- b/doc/src/sgml/ref/pg_ctl-ref.sgml	Thu May  8 13:48:13 2014
*************** PostgreSQL documentation
*** 115,120 ****
--- 115,121 ----
         <arg choice="plain"><option>d[emand]</option></arg>
       </group>
     </arg>
+    <arg choice="opt"><option>-e</option> <replaceable>event-source</replaceable></arg>
     <arg choice="opt"><option>-w</option></arg>
     <arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
     <arg choice="opt"><option>-s</option></arg>
*************** PostgreSQL documentation
*** 420,425 ****
--- 421,436 ----
  
     <variablelist>
      <varlistentry>
+      <term><option>-e <replaceable class="parameter">event-source</replaceable></option></term>
+      <listitem>
+       <para>
+        Name of the event source for pg_ctl to use for event log when it
+        is running as a Windows service.  The default is PostgreSQL.
+       </para>
+      </listitem>
+     </varlistentry>
+ 
+     <varlistentry>
       <term><option>-N <replaceable class="parameter">servicename</replaceable></option></term>
       <listitem>
        <para>
diff -rpcd a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
*** a/src/backend/utils/error/elog.c	Thu May  8 09:17:03 2014
--- b/src/backend/utils/error/elog.c	Thu May  8 12:15:34 2014
*************** write_eventlog(int level, const char *li
*** 1989,1995 ****
  
  	if (evtHandle == INVALID_HANDLE_VALUE)
  	{
! 		evtHandle = RegisterEventSource(NULL, event_source ? event_source : "PostgreSQL");
  		if (evtHandle == NULL)
  		{
  			evtHandle = INVALID_HANDLE_VALUE;
--- 1989,1996 ----
  
  	if (evtHandle == INVALID_HANDLE_VALUE)
  	{
! 		evtHandle = RegisterEventSource(NULL,
! 						 event_source ? event_source : DEFAULT_EVENT_SOURCE);
  		if (evtHandle == NULL)
  		{
  			evtHandle = INVALID_HANDLE_VALUE;
diff -rpcd a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
*** a/src/backend/utils/misc/guc.c	Thu May  8 09:17:02 2014
--- b/src/backend/utils/misc/guc.c	Thu May  8 12:15:34 2014
*************** static struct config_string ConfigureNam
*** 3022,3028 ****
  			NULL
  		},
  		&event_source,
! 		"PostgreSQL",
  		NULL, NULL, NULL
  	},
  
--- 3022,3028 ----
  			NULL
  		},
  		&event_source,
! 		DEFAULT_EVENT_SOURCE,
  		NULL, NULL, NULL
  	},
  
Only in b/src/backend/utils/misc: guc.c.orig
diff -rpcd a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
*** a/src/bin/pg_ctl/pg_ctl.c	Thu May  8 09:17:03 2014
--- b/src/bin/pg_ctl/pg_ctl.c	Thu May  8 12:19:04 2014
*************** static char *post_opts = NULL;
*** 89,94 ****
--- 89,95 ----
  static const char *progname;
  static char *log_file = NULL;
  static char *exec_path = NULL;
+ static char *event_source = NULL;
  static char *register_servicename = "PostgreSQL";		/* FIXME: + version ID? */
  static char *register_username = NULL;
  static char *register_password = NULL;
*************** write_eventlog(int level, const char *li
*** 178,184 ****
  
  	if (evtHandle == INVALID_HANDLE_VALUE)
  	{
! 		evtHandle = RegisterEventSource(NULL, "PostgreSQL");
  		if (evtHandle == NULL)
  		{
  			evtHandle = INVALID_HANDLE_VALUE;
--- 179,186 ----
  
  	if (evtHandle == INVALID_HANDLE_VALUE)
  	{
! 		evtHandle = RegisterEventSource(NULL,
! 						event_source ? event_source : DEFAULT_EVENT_SOURCE);
  		if (evtHandle == NULL)
  		{
  			evtHandle = INVALID_HANDLE_VALUE;
*************** pgwin32_CommandLine(bool registration)
*** 1407,1412 ****
--- 1409,1417 ----
  		free(dataDir);
  	}
  
+ 	if (registration && event_source != NULL)
+ 		appendPQExpBuffer(cmdLine, " -e \"%s\"", event_source);
+ 
  	if (registration && do_wait)
  		appendPQExpBuffer(cmdLine, " -w");
  
*************** do_help(void)
*** 1872,1878 ****
  	printf(_("  %s kill    SIGNALNAME PID\n"), progname);
  #if defined(WIN32) || defined(__CYGWIN__)
  	printf(_("  %s register   [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR]\n"
! 			 "                    [-S START-TYPE] [-w] [-t SECS] [-o \"OPTIONS\"]\n"), progname);
  	printf(_("  %s unregister [-N SERVICENAME]\n"), progname);
  #endif
  
--- 1877,1883 ----
  	printf(_("  %s kill    SIGNALNAME PID\n"), progname);
  #if defined(WIN32) || defined(__CYGWIN__)
  	printf(_("  %s register   [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR]\n"
! 			 "                    [-S START-TYPE] [-e event-source] [-w] [-t SECS] [-o \"OPTIONS\"]\n"), progname);
  	printf(_("  %s unregister [-N SERVICENAME]\n"), progname);
  #endif
  
*************** do_help(void)
*** 1911,1916 ****
--- 1916,1922 ----
  #if defined(WIN32) || defined(__CYGWIN__)
  	printf(_("\nOptions for register and unregister:\n"));
  	printf(_("  -N SERVICENAME  service name with which to register PostgreSQL server\n"));
+ 	printf(_("  -e event-source  event source for pg_ctl to use for event log\n"));
  	printf(_("  -P PASSWORD     password of account to register PostgreSQL server\n"));
  	printf(_("  -U USERNAME     user name of account to register PostgreSQL server\n"));
  	printf(_("  -S START-TYPE   service start type to register PostgreSQL server\n"));
*************** main(int argc, char **argv)
*** 2141,2147 ****
  	/* process command-line options */
  	while (optind < argc)
  	{
! 		while ((c = getopt_long(argc, argv, "cD:l:m:N:o:p:P:sS:t:U:wW", long_options, &option_index)) != -1)
  		{
  			switch (c)
  			{
--- 2147,2153 ----
  	/* process command-line options */
  	while (optind < argc)
  	{
! 		while ((c = getopt_long(argc, argv, "cD:e:l:m:N:o:p:P:sS:t:U:wW", long_options, &option_index)) != -1)
  		{
  			switch (c)
  			{
*************** main(int argc, char **argv)
*** 2169,2174 ****
--- 2175,2183 ----
  				case 'm':
  					set_mode(optarg);
  					break;
+ 				case 'e':
+ 					event_source = pg_strdup(optarg);
+ 					break;
  				case 'N':
  					register_servicename = pg_strdup(optarg);
  					break;
Only in b/src/bin/pg_ctl: pg_ctl.c.orig
diff -rpcd a/src/bin/pgevent/pgevent.c b/src/bin/pgevent/pgevent.c
*** a/src/bin/pgevent/pgevent.c	Thu May  8 09:17:03 2014
--- b/src/bin/pgevent/pgevent.c	Thu May  8 12:15:34 2014
***************
*** 12,17 ****
--- 12,19 ----
   */
  
  
+ #include "postgres_fe.h"
+ 
  #include <windows.h>
  #include <olectl.h>
  #include <string.h>
*************** HANDLE		g_module = NULL;	/* hModule of D
*** 26,32 ****
   * The maximum length of a registry key is 255 characters.
   * http://msdn.microsoft.com/en-us/library/ms724872(v=vs.85).aspx
   */
! char		event_source[256] = "PostgreSQL";
  
  /* Prototypes */
  HRESULT		DllInstall(BOOL bInstall, LPCWSTR pszCmdLine);
--- 28,34 ----
   * The maximum length of a registry key is 255 characters.
   * http://msdn.microsoft.com/en-us/library/ms724872(v=vs.85).aspx
   */
! char		event_source[256] = DEFAULT_EVENT_SOURCE;
  
  /* Prototypes */
  HRESULT		DllInstall(BOOL bInstall, LPCWSTR pszCmdLine);
*************** DllInstall(BOOL bInstall,
*** 54,64 ****
  	 *
  	 * This strange behavior forces us to specify -n (i.e. "regsvr32 /n /i").
  	 * Without -n, DllRegisterServer called before DllInstall would mistakenly
! 	 * overwrite the default "PostgreSQL" event source registration.
  	 */
  	if (bInstall)
! 		DllRegisterServer();
! 	return S_OK;
  }
  
  /*
--- 56,67 ----
  	 *
  	 * This strange behavior forces us to specify -n (i.e. "regsvr32 /n /i").
  	 * Without -n, DllRegisterServer called before DllInstall would mistakenly
! 	 * overwrite the default event source registration.
  	 */
  	if (bInstall)
! 		return DllRegisterServer();
! 	else
! 		return S_OK;
  }
  
  /*
*************** DllRegisterServer(void)
*** 72,77 ****
--- 75,81 ----
  	DWORD		data;
  	char		buffer[_MAX_PATH];
  	char		key_name[400];
+ 	char		message[1024];
  
  	/* Set the name of DLL full path name. */
  	if (!GetModuleFileName((HMODULE) g_module, buffer, sizeof(buffer)))
*************** DllRegisterServer(void)
*** 87,97 ****
  	_snprintf(key_name, sizeof(key_name),
  			"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s",
  			  event_source);
! 	if (RegCreateKey(HKEY_LOCAL_MACHINE, key_name, &key))
  	{
  		MessageBox(NULL, "Could not create the registry key.", "PostgreSQL error", MB_OK | MB_ICONSTOP);
  		return SELFREG_E_TYPELIB;
  	}
  
  	/* Add the name to the EventMessageFile subkey. */
  	if (RegSetValueEx(key,
--- 91,110 ----
  	_snprintf(key_name, sizeof(key_name),
  			"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s",
  			  event_source);
! 	if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, key_name, 0, NULL, 0, KEY_WRITE,
! 		NULL, &key, &data))
  	{
  		MessageBox(NULL, "Could not create the registry key.", "PostgreSQL error", MB_OK | MB_ICONSTOP);
  		return SELFREG_E_TYPELIB;
  	}
+ 	else if (data == REG_OPENED_EXISTING_KEY)
+ 	{
+ 		RegCloseKey(key);
+ 		_snprintf(message, sizeof(message),
+ 				"Event source \"%s\" is already registered.", event_source);
+ 		MessageBox(NULL, message, "PostgreSQL error", MB_OK | MB_ICONSTOP);
+ 		return SELFREG_E_TYPELIB;
+ 	}
  
  	/* Add the name to the EventMessageFile subkey. */
  	if (RegSetValueEx(key,
diff -rpcd a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
*** a/src/include/pg_config_manual.h	Thu May  8 09:17:02 2014
--- b/src/include/pg_config_manual.h	Thu May  8 12:15:34 2014
***************
*** 155,160 ****
--- 155,165 ----
  #define DEFAULT_PGSOCKET_DIR  "/tmp"
  
  /*
+  * This is the default event source for Windows event log.
+  */
+ #define DEFAULT_EVENT_SOURCE  "PostgreSQL"
+ 
+ /*
   * The random() function is expected to yield values between 0 and
   * MAX_RANDOM_VALUE.  Currently, all known implementations yield
   * 0..2^31-1, so we just hardwire this constant.  We could do a
