From d27addc694c75a0f4aee293bcc5ee5eba6d4f6cf Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 11 Jul 2021 17:07:23 +0800 Subject: [PATCH] Update LogConfigurator.cs The part of filename "{DateTime.Now:yyyy-dd-M--HH-mm-ss}-{Process.GetCurrentProcess().Id}" generates tons of log files with same content but different per-second/thread filenames until the harddisk have 0KB space left. This kept happening in my AWS EC2 machine until I found the big GBs-size log file in temp folder caused by this line. Changing the filename to $"{DateTime.Now:yyyy-MM-dd}.{LogFileNameExtension}" solved the issue. The timestamp and processId can still be found in the log content. --- MTApiService/LogConfigurator.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MTApiService/LogConfigurator.cs b/MTApiService/LogConfigurator.cs index 65833989..f919de3f 100755 --- a/MTApiService/LogConfigurator.cs +++ b/MTApiService/LogConfigurator.cs @@ -90,7 +90,8 @@ namespace MTApiService }; patternLayout.ActivateOptions(); - var filename = $"{DateTime.Now:yyyy-dd-M--HH-mm-ss}-{Process.GetCurrentProcess().Id}.{LogFileNameExtension}"; + //var filename = $"{DateTime.Now:yyyy-dd-M--HH-mm-ss}-{Process.GetCurrentProcess().Id}.{LogFileNameExtension}"; // This filename format keeps generating tons of log files with same content but different per-second/thread filenames until the harddisk have 0KB space left + var filename = $"{DateTime.Now:yyyy-MM-dd}.{LogFileNameExtension}"; var roller = new RollingFileAppender {