diff --git a/backend-service/cmd/main.go b/backend-service/cmd/main.go index 21af4f6..be3d683 100644 --- a/backend-service/cmd/main.go +++ b/backend-service/cmd/main.go @@ -320,7 +320,19 @@ func startDaemonProcess() error { } goTimeFormat := formatGoTime(constants.LogNameFormate) logFileName := time.Now().Format(goTimeFormat) - logFilePath := filepath.Join(constants.LogFilePath, logFileName) + // logFilePath := filepath.Join(constants.LogFilePath, logFileName) + var logFilePath string + if isDebug() { + logFilePath = filepath.Join(constants.LogFilePath, logFileName) + } else { + exePath, err := os.Executable() + if err != nil { + logger.Error("Error getting executable path: %v", err) + return err + } + exeDir := filepath.Dir(exePath) + logFilePath = filepath.Join(exeDir, constants.LogFilePath, logFileName) + } logFile, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, constants.LogFileMode) if err != nil { return fmt.Errorf("open log file: %w", err)