From 3d9683f290d584f66818d8cc00c5cb468404ce39 Mon Sep 17 00:00:00 2001
From: allegroai <>
Date: Tue, 28 Apr 2020 10:44:40 +0300
Subject: [PATCH] Fix logger creation guard

---
 trains/task.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/trains/task.py b/trains/task.py
index 99dab3cd..e6b6426e 100644
--- a/trains/task.py
+++ b/trains/task.py
@@ -1557,11 +1557,10 @@ class Task(_Task):
         :return: Logger object
         """
 
-        # do not recreate logger after task was closed/quit
-        if self._at_exit_called:
-            raise ValueError("Cannot use Task Logger after task was closed")
-
         if not self._logger:
+            # do not recreate logger after task was closed/quit
+            if self._at_exit_called:
+                raise ValueError("Cannot use Task Logger after task was closed")
             # force update of base logger to this current task (this is the main logger task)
             self._setup_log(replace_existing=self.is_main_task())
             # Get a logger object