diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 0867cc4..77d24f5 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -184,6 +184,8 @@ static volatile sig_atomic_t replication_active = false;
 static LogicalDecodingContext *logical_decoding_ctx = NULL;
 static XLogRecPtr logical_startptr = InvalidXLogRecPtr;
 
+static void walsnd_proc_exit(int code);
+
 /* Signal handlers */
 static void WalSndSigHupHandler(SIGNAL_ARGS);
 static void WalSndXLogSendHandler(SIGNAL_ARGS);
@@ -242,6 +244,23 @@ InitWalSender(void)
 	SendPostmasterSignal(PMSIGNAL_ADVANCE_STATE_MACHINE);
 }
 
+static void
+walsnd_proc_exit(int code)
+{
+	WalSnd *walsnd = MyWalSnd;
+	int mypriority = 0;
+
+	SpinLockAcquire(&walsnd->mutex);
+	mypriority = walsnd->sync_standby_priority;
+	SpinLockRelease(&walsnd->mutex);
+
+	if (mypriority > 0)
+		ereport(LOG,
+				(errmsg("synchronous standby \"%s\" with priority %d exited",
+						application_name, mypriority)));
+	proc_exit(code);
+}
+
 /*
  * Clean up after an error.
  *
@@ -266,7 +285,7 @@ WalSndErrorCleanup(void)
 
 	replication_active = false;
 	if (walsender_ready_to_stop)
-		proc_exit(0);
+		walsnd_proc_exit(0);
 
 	/* Revert back to startup state */
 	WalSndSetState(WALSNDSTATE_STARTUP);
@@ -285,7 +304,7 @@ WalSndShutdown(void)
 	if (whereToSendOutput == DestRemote)
 		whereToSendOutput = DestNone;
 
-	proc_exit(0);
+	walsnd_proc_exit(0);
 	abort();					/* keep the compiler quiet */
 }
 
@@ -673,7 +692,7 @@ StartReplication(StartReplicationCmd *cmd)
 
 		replication_active = false;
 		if (walsender_ready_to_stop)
-			proc_exit(0);
+			walsnd_proc_exit(0);
 		WalSndSetState(WALSNDSTATE_STARTUP);
 
 		Assert(streamingDoneSending && streamingDoneReceiving);
@@ -1027,7 +1046,7 @@ StartLogicalReplication(StartReplicationCmd *cmd)
 
 	replication_active = false;
 	if (walsender_ready_to_stop)
-		proc_exit(0);
+		walsnd_proc_exit(0);
 	WalSndSetState(WALSNDSTATE_STARTUP);
 
 	/* Get out of COPY mode (CommandComplete). */
@@ -1391,7 +1410,7 @@ ProcessRepliesIfAny(void)
 			ereport(COMMERROR,
 					(errcode(ERRCODE_PROTOCOL_VIOLATION),
 					 errmsg("unexpected EOF on standby connection")));
-			proc_exit(0);
+			walsnd_proc_exit(0);
 		}
 		if (r == 0)
 		{
@@ -1407,7 +1426,7 @@ ProcessRepliesIfAny(void)
 			ereport(COMMERROR,
 					(errcode(ERRCODE_PROTOCOL_VIOLATION),
 					 errmsg("unexpected EOF on standby connection")));
-			proc_exit(0);
+			walsnd_proc_exit(0);
 		}
 
 		/*
@@ -1453,7 +1472,7 @@ ProcessRepliesIfAny(void)
 				 * 'X' means that the standby is closing down the socket.
 				 */
 			case 'X':
-				proc_exit(0);
+				walsnd_proc_exit(0);
 
 			default:
 				ereport(FATAL,
@@ -1500,7 +1519,7 @@ ProcessStandbyMessage(void)
 			ereport(COMMERROR,
 					(errcode(ERRCODE_PROTOCOL_VIOLATION),
 					 errmsg("unexpected message type \"%c\"", msgtype)));
-			proc_exit(0);
+			walsnd_proc_exit(0);
 	}
 }
 
@@ -2501,7 +2520,7 @@ WalSndDone(WalSndSendDataCallback send_data)
 		EndCommand("COPY 0", DestRemote);
 		pq_flush();
 
-		proc_exit(0);
+		walsnd_proc_exit(0);
 	}
 	if (!waiting_for_ping_response)
 		WalSndKeepalive(true);
