diff --git a/satella/db.py b/satella/db.py
index 03157ab843b393f53472b67bfc41ee6507710da5..13b5d08f190fd62180f6a2b14ea263ea4eec3f5d 100644
--- a/satella/db.py
+++ b/satella/db.py
@@ -37,7 +37,7 @@ class transaction:
         else:
             self.connection.rollback()
 
-        if exc_val is None and self.log_exception:
+        if exc_val is not None and self.log_exception:
             logger.error('Exception occurred of type %s', exc_type, exc_info=exc_val)
 
         self.cursor.close()