diff -uNrp zabbix-4.0.12.orig/include/common.h zabbix-4.0.12/include/common.h
--- zabbix-4.0.12.orig/include/common.h	2019-08-26 21:12:22.000000000 +0900
+++ zabbix-4.0.12/include/common.h	2019-09-02 15:07:01.553883302 +0900
@@ -425,6 +425,7 @@ zbx_graph_yaxis_types_t;
 #define ZBX_HOUSEKEEPER_EXECUTE	"housekeeper_execute"
 #define ZBX_LOG_LEVEL_INCREASE	"log_level_increase"
 #define ZBX_LOG_LEVEL_DECREASE	"log_level_decrease"
+#define ZBX_LOGFILE_REDIRECT	"logfile_redirect"
 
 /* value for not supported items */
 #define ZBX_NOTSUPPORTED	"ZBX_NOTSUPPORTED"
@@ -892,6 +893,7 @@ zbx_task_t;
 #define ZBX_RTC_LOG_LEVEL_DECREASE	2
 #define ZBX_RTC_HOUSEKEEPER_EXECUTE	3
 #define ZBX_RTC_CONFIG_CACHE_RELOAD	8
+#define ZBX_RTC_LOGFILE_REDIRECT	9
 
 typedef enum
 {
diff -uNrp zabbix-4.0.12.orig/include/log.h zabbix-4.0.12/include/log.h
--- zabbix-4.0.12.orig/include/log.h	2019-08-26 21:12:22.000000000 +0900
+++ zabbix-4.0.12/include/log.h	2019-09-02 15:05:16.715091202 +0900
@@ -91,6 +91,7 @@ char		*strerror_from_module(unsigned lon
 void		zbx_redirect_stdio(const char *filename);
 
 void		zbx_handle_log(void);
+void		zbx_handle_log2(void);
 
 int		zbx_get_log_type(const char *logtype);
 int		zbx_validate_log_parameters(ZBX_TASK_EX *task);
diff -uNrp zabbix-4.0.12.orig/src/libs/zbxlog/log.c zabbix-4.0.12/src/libs/zbxlog/log.c
--- zabbix-4.0.12.orig/src/libs/zbxlog/log.c	2019-08-26 21:12:22.000000000 +0900
+++ zabbix-4.0.12/src/libs/zbxlog/log.c	2019-09-02 15:05:16.716091209 +0900
@@ -272,6 +272,15 @@ static void	unlock_log(void)
 }
 #endif
 
+void zbx_handle_log2(void)
+{
+	LOCK_LOG;
+
+	zbx_redirect_stdio(log_filename);
+
+	UNLOCK_LOG;
+}
+
 void	zbx_handle_log(void)
 {
 	if (LOG_TYPE_FILE != log_type)
diff -uNrp zabbix-4.0.12.orig/src/libs/zbxnix/control.c zabbix-4.0.12/src/libs/zbxnix/control.c
--- zabbix-4.0.12.orig/src/libs/zbxnix/control.c	2019-08-26 21:12:22.000000000 +0900
+++ zabbix-4.0.12/src/libs/zbxnix/control.c	2019-09-02 15:05:16.716091209 +0900
@@ -154,6 +154,13 @@ int	parse_rtc_options(const char *opt, u
 		scope = 0;
 		data = 0;
 	}
+	else if (0 != (program_type & (ZBX_PROGRAM_TYPE_SERVER | ZBX_PROGRAM_TYPE_PROXY | ZBX_PROGRAM_TYPE_AGENTD)) &&
+			0 == strcmp(opt, ZBX_LOGFILE_REDIRECT))
+	{
+		command = ZBX_RTC_LOGFILE_REDIRECT;
+		scope = 0;
+		data = 0;
+	}
 	else
 	{
 		zbx_error("invalid runtime control option: %s", opt);
diff -uNrp zabbix-4.0.12.orig/src/libs/zbxnix/daemon.c zabbix-4.0.12/src/libs/zbxnix/daemon.c
--- zabbix-4.0.12.orig/src/libs/zbxnix/daemon.c	2019-08-26 21:12:22.000000000 +0900
+++ zabbix-4.0.12/src/libs/zbxnix/daemon.c	2019-09-02 15:05:16.716091209 +0900
@@ -80,6 +80,9 @@ static void	common_sigusr_handler(int fl
 						zabbix_get_log_level_string());
 			}
 			break;
+		case ZBX_RTC_LOGFILE_REDIRECT:
+			zbx_handle_log2();
+			break;
 		default:
 			if (NULL != zbx_sigusr_handler)
 				zbx_sigusr_handler(flags);
@@ -234,6 +237,10 @@ static void	user1_signal_handler(int sig
 			else
 				zbx_signal_process_by_type(ZBX_RTC_GET_SCOPE(flags), ZBX_RTC_GET_DATA(flags), flags);
 			break;
+		case ZBX_RTC_LOGFILE_REDIRECT:
+			zbx_signal_process_by_pid(0, flags);
+			zbx_handle_log2();
+			break;
 	}
 #endif
 }
diff -uNrp zabbix-4.0.12.orig/src/zabbix_agent/zabbix_agentd.c zabbix-4.0.12/src/zabbix_agent/zabbix_agentd.c
--- zabbix-4.0.12.orig/src/zabbix_agent/zabbix_agentd.c	2019-08-26 21:12:22.000000000 +0900
+++ zabbix-4.0.12/src/zabbix_agent/zabbix_agentd.c	2019-09-02 15:05:16.716091209 +0900
@@ -180,6 +180,7 @@ const char	*help_message[] = {
 	"        process-type,N           Process type and number (e.g., listener,3)",
 	"        pid                      Process identifier, up to 65535. For larger",
 	"                                 values specify target as \"process-type,N\"",
+  "      " ZBX_LOGFILE_REDIRECT "        Redirect stdout and stderr to the new logfile",
 #endif
 	"",
 	"  -h --help                      Display this help message",
diff -uNrp zabbix-4.0.12.orig/src/zabbix_proxy/proxy.c zabbix-4.0.12/src/zabbix_proxy/proxy.c
--- zabbix-4.0.12.orig/src/zabbix_proxy/proxy.c	2019-08-26 21:12:22.000000000 +0900
+++ zabbix-4.0.12/src/zabbix_proxy/proxy.c	2019-09-02 15:05:16.716091209 +0900
@@ -102,6 +102,7 @@ const char	*help_message[] = {
 	"        process-type,N           Process type and number (e.g., poller,3)",
 	"        pid                      Process identifier, up to 65535. For larger",
 	"                                 values specify target as \"process-type,N\"",
+  "      " ZBX_LOGFILE_REDIRECT "        Redirect stdout and stderr to the new logfile",
 	"",
 	"  -h --help                      Display this help message",
 	"  -V --version                   Display version number",
diff -uNrp zabbix-4.0.12.orig/src/zabbix_server/server.c zabbix-4.0.12/src/zabbix_server/server.c
--- zabbix-4.0.12.orig/src/zabbix_server/server.c	2019-08-26 21:12:22.000000000 +0900
+++ zabbix-4.0.12/src/zabbix_server/server.c	2019-09-02 15:05:16.716091209 +0900
@@ -116,6 +116,7 @@ const char	*help_message[] = {
 	"        process-type,N           Process type and number (e.g., poller,3)",
 	"        pid                      Process identifier, up to 65535. For larger",
 	"                                 values specify target as \"process-type,N\"",
+	"      " ZBX_LOGFILE_REDIRECT "        Redirect stdout and stderr to the new logfile",
 	"",
 	"  -h --help                      Display this help message",
 	"  -V --version                   Display version number",
