diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index dbb10c7..f56b557 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -1369,14 +1369,6 @@ exec_replication_command(const char *cmd_string)
 	MemoryContext old_context;
 
 	/*
-	 * Log replication command if log_replication_commands is enabled. Even
-	 * when it's disabled, log the command with DEBUG1 level for backward
-	 * compatibility.
-	 */
-	ereport(log_replication_commands ? LOG : DEBUG1,
-			(errmsg("received replication command: %s", cmd_string)));
-
-	/*
 	 * CREATE_REPLICATION_SLOT ... LOGICAL exports a snapshot until the next
 	 * command arrives. Clean up the old stuff if there's anything.
 	 */
@@ -1400,6 +1392,17 @@ exec_replication_command(const char *cmd_string)
 	cmd_node = replication_parse_result;
 
 	/*
+	 * Log replication command if log_replication_commands is enabled. Even
+	 * when it's disabled, log the command with DEBUG1 level for backward
+	 * compatibility. SQL commmands are logged later according to log_statement
+	 * setting. To prevent the command is logged doubly, we doesn't log it
+	 * when the command is a SQL command.
+	 */
+	if (cmd_node->type != T_SQLCmd)
+		ereport(log_replication_commands ? LOG : DEBUG1,
+				(errmsg("received replication command: %s", cmd_string)));
+
+	/*
 	 * CREATE_REPLICATION_SLOT ... LOGICAL exports a snapshot. If it was
 	 * called outside of transaction the snapshot should be cleared here.
 	 */
