diff --git a/rules.services.yml b/rules.services.yml
index 12da00052f93b584a2d4c64d85c5f63cbbd0ee0a..9e2c2de6b5fc878e6439fd31c345996ddebbb781 100644
--- a/rules.services.yml
+++ b/rules.services.yml
@@ -25,7 +25,7 @@ services:
     arguments: ['rules']
   logger.channel.rules_debug:
     class: Drupal\rules\Logger\RulesDebugLoggerChannel
-    arguments: ['@logger.channel.rules', '@config.factory', '@messenger']
+    arguments: ['@logger.rules_debug_log', '@config.factory']
   logger.rules_debug_log:
     class: Drupal\rules\Logger\RulesDebugLog
     arguments: ['@session']
diff --git a/src/Engine/RulesComponent.php b/src/Engine/RulesComponent.php
index 5e2733b32fd2fdc17968fb467fbc432bdb96c167..0e798f6d4fa51f0b91a2a68e6e639cc96cda1980 100644
--- a/src/Engine/RulesComponent.php
+++ b/src/Engine/RulesComponent.php
@@ -234,14 +234,14 @@ class RulesComponent {
     // @todo Use injection for the service.
     $rulesDebugLogger = \Drupal::service('logger.channel.rules_debug');
     $rulesDebugLogger->info('RulesComponent: Rule %label fires.', [
-      '%label' => $this->expression->getRoot()->getLabel(),
-      'element' => $this,
+      '%label' => $this->expression->getLabel(),
+      'element' => $this->expression,
       'scope' => TRUE,
     ]);
     $this->expression->executeWithState($this->state);
     $rulesDebugLogger->info('RulesComponent: Rule %label has fired.', [
-      '%label' => $this->expression->getRoot()->getLabel(),
-      'element' => $this,
+      '%label' => $this->expression->getLabel(),
+      'element' => $this->expression,
       'scope' => FALSE,
     ]);
 
diff --git a/src/Logger/RulesDebugLog.php b/src/Logger/RulesDebugLog.php
index 5a39894e1034604aea47df6b8259a92f4e70ff3d..2f3652da59ac649fac7f4e57396cb2a3e27a7cb1 100644
--- a/src/Logger/RulesDebugLog.php
+++ b/src/Logger/RulesDebugLog.php
@@ -4,7 +4,7 @@ namespace Drupal\rules\Logger;
 
 use Psr\Log\LoggerInterface;
 use Psr\Log\LoggerTrait;
-use Symfony\Component\HttpFoundation\Session\Session;
+use Symfony\Component\HttpFoundation\Session\SessionInterface;
 
 /**
  * Logger that stores Rules debug logs with the session service.
@@ -18,17 +18,17 @@ class RulesDebugLog implements LoggerInterface {
   /**
    * The session service.
    *
-   * @var \Symfony\Component\HttpFoundation\Session\Session
+   * @var \Symfony\Component\HttpFoundation\Session\SessionInterface
    */
   protected $session;
 
   /**
    * Constructs a RulesDebugLog object.
    *
-   * @param \Symfony\Component\HttpFoundation\Session\Session $session
+   * @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
    *   The session service.
    */
-  public function __construct(Session $session) {
+  public function __construct(SessionInterface $session) {
     $this->session = $session;
   }
 
@@ -56,8 +56,8 @@ class RulesDebugLog implements LoggerInterface {
       'path' => $context['path'],
     ];
 
-    // Write the $localCopy array back into the session.
-    // It now includes the new log.
+    // Write the $localCopy array back into the session;
+    // it now includes the new log.
     $this->session->set('rules_debug_log', $localCopy);
   }
 
@@ -71,7 +71,8 @@ class RulesDebugLog implements LoggerInterface {
    *   - context: An array of message placeholder replacements.
    *   - level: \Psr\Log\LogLevel level.
    *   - timestamp: Microtime timestamp in float format.
-   *   - scope: TRUE if there are nested logs for this entry.
+   *   - scope: TRUE if there are nested logs for this entry, FALSE if this is
+   *     the last of the nested entries.
    *   - path: Path to edit this component.
    */
   public function getLogs() {
diff --git a/src/Logger/RulesDebugLoggerChannel.php b/src/Logger/RulesDebugLoggerChannel.php
index 0dff3bbec5214b26514b6d3d6c1dc1c78c4416aa..9c0bccd6580fa010a239dc585204d7945e61c1d7 100644
--- a/src/Logger/RulesDebugLoggerChannel.php
+++ b/src/Logger/RulesDebugLoggerChannel.php
@@ -4,7 +4,7 @@ namespace Drupal\rules\Logger;
 
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Logger\LoggerChannel;
-use Drupal\Core\Messenger\MessengerInterface;
+use Drupal\Core\Url;
 use Psr\Log\LoggerInterface;
 
 /**
@@ -13,92 +13,119 @@ use Psr\Log\LoggerInterface;
 class RulesDebugLoggerChannel extends LoggerChannel {
 
   /**
-   * The logger.
+   * The Rules debug log.
    *
    * @var \Psr\Log\LoggerInterface
    */
-  protected $logger;
+  protected $rulesDebugLog;
 
   /**
    * A configuration object with rules settings.
    *
-   * @var \Drupal\Core\Config\ImmutableConfig
+   * @var \Drupal\Core\Config\ConfigFactoryInterface
    */
   protected $config;
 
-  /**
-   * The messenger service.
-   *
-   * @var \Drupal\Core\Messenger\MessengerInterface
-   */
-  protected $messenger;
-
-  /**
-   * Static storage of log entries.
-   *
-   * @var array
-   */
-  protected $logs = [];
-
   /**
    * Creates RulesDebugLoggerChannel object.
    *
-   * @param \Psr\Log\LoggerInterface $logger
-   *   The logger.
+   * @param \Psr\Log\LoggerInterface $rules_debug_log
+   *   The Rules debug log.
    * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
    *   Config factory instance.
-   * @param \Drupal\Core\Messenger\MessengerInterface $messenger
-   *   The messenger service.
    */
-  public function __construct(LoggerInterface $logger, ConfigFactoryInterface $config_factory, MessengerInterface $messenger) {
+  public function __construct(LoggerInterface $rules_debug_log, ConfigFactoryInterface $config_factory) {
     parent::__construct('rules_debug');
-    $this->logger = $logger;
+    $this->rulesDebugLog = $rules_debug_log;
     $this->config = $config_factory;
-    $this->messenger = $messenger;
   }
 
   /**
    * {@inheritdoc}
+   *
+   * Parent log() function is overridden to use microtime() for Rules execution
+   * times and to prepare additional variables to pass to the logger. These
+   * variables hold the extra call parameters used by RulesDebugLog for
+   * backtracing. These are passed in via $context[] where they will be ignored
+   * by any module that doesn't know about them ...
    */
   public function log($level, $message, array $context = []) {
-    // Log message only if rules logging setting is enabled.
+    // Log debugging information only if the debug_log.enabled setting is
+    // enabled. Otherwise exit immediately.
     $config = $this->config->get('rules.settings');
-    if ($config->get('debug_log.system_debug')) {
-      if ($this->levelTranslation[$config->get('system_log.log_level')] >= $this->levelTranslation[$level]) {
-        parent::log($level, $message, $context);
-      }
+    if (!$config->get('debug_log.enabled')) {
+      return;
     }
-    if ($config->get('debug_log.enabled')) {
-      $rfc_level = $level;
-      if (is_string($level)) {
-        $rfc_level = $this->levelTranslation[$level];
-      }
-      if ($this->levelTranslation[$config->get('debug_log.log_level')] >= $rfc_level) {
-        $this->logs[] = [
-          'level' => $level,
-          'message' => $message,
-          'context' => $context,
-        ];
-        $this->messenger->addMessage($message, $level);
+
+    if ($this->callDepth == self::MAX_CALL_DEPTH) {
+      return;
+    }
+    $this->callDepth++;
+
+    // Merge in defaults normally provided by the parent LoggerChannel class.
+    $context += [
+      'channel' => $this->channel,
+      'link' => '',
+      'uid' => 0,
+      'request_uri' => '',
+      'referer' => '',
+      'ip' => '',
+      'timestamp' => microtime(TRUE),
+    ];
+
+    // Some context values are only available when in a request context.
+    if ($this->requestStack && ($request = $this->requestStack->getCurrentRequest())) {
+      $context['request_uri'] = $request->getUri();
+      $context['referer'] = $request->headers->get('Referer', '');
+      $context['ip'] = $request->getClientIP();
+      if ($this->currentUser) {
+        $context['uid'] = $this->currentUser->id();
       }
     }
-  }
 
-  /**
-   * Returns the structured array of entries.
-   *
-   * @return array
-   *   Array of stored log entries.
-   */
-  public function getLogs() {
-    return $this->logs;
-  }
+    // Extract the Rules-specific defaults from $context.
+    $element = isset($context['element']) ? $context['element'] : NULL;
+    $scope = isset($context['scope']) ? $context['scope'] : NULL;
+    $path = isset($context['path']) ? $context['path'] : NULL;
 
-  /**
-   * Clears the static logs entries cache.
-   */
-  public function clearLogs() {
-    $this->logs = [];
+    if (!empty($element)) {
+      $uuid = $element->getUuid();
+      $path = $element->getRoot()->getLabel() ? Url::fromRoute('entity.rules_reaction_rule.edit_form', ['rules_reaction_rule' => $element->getRoot()->getPluginId()])->toString() : NULL;
+      $path = $path . '/edit/' . $uuid;
+    }
+
+    // Pack $element, $scope, and $path into the context array so as to forward
+    // them to the logger.channel.rules_debug logger channel for logging.
+    $context += [
+      'element' => $element,
+      'scope' => $scope,
+      'path' => $path,
+    ];
+    // Now, write the logs to the RulesDebugLog to store in memory. This is the
+    // principal reason for this class! Keep the array structure we used in D7
+    // so we don't have to re-write the theming functions and JavaScript too
+    // much. We added keys for D8 so we don't have to guess the contents of the
+    // array elemens from their order index.
+
+    $rfc_level = $level;
+    if (is_string($level)) {
+      // Convert to integer equivalent for consistency with RFC 5424.
+      $rfc_level = $this->levelTranslation[$level];
+    }
+
+    // A lesser RFC level is MORE severe, so we want to test if the RFC level
+    // of the message is LESS than or equal to the threshold level setting.
+    if ($this->levelTranslation[$config->get('debug_log.log_level')] >= $rfc_level) {
+      $this->rulesDebugLog->log($level, $message, $context);
+
+      // Support any loggers added through the API, just because we can (most
+      // of this is inherited from parent LoggerChannel class).
+      foreach ($this->sortLoggers() as $logger) {
+        $logger->log($rfc_level, $message, $context);
+      }
+    }
+
+    $this->callDepth--;
   }
 
 }
diff --git a/src/Logger/RulesLog.php b/src/Logger/RulesLog.php
index 22abad7d3a98e586d159e8ce625cb39470c19760..c5c2e23eb57c8997531a577913e5af7eecd07e96 100644
--- a/src/Logger/RulesLog.php
+++ b/src/Logger/RulesLog.php
@@ -10,7 +10,7 @@ use Psr\Log\LoggerInterface;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 
 /**
- * Dispatches new logger-items as SystemLoggerEvent.
+ * Logger that dispatches a SystemLoggerEvent when a logger entry is made.
  */
 class RulesLog implements LoggerInterface {
   use RfcLoggerTrait;
diff --git a/tests/src/Kernel/ConfigEntityTest.php b/tests/src/Kernel/ConfigEntityTest.php
index bc42270ecaf6c29eb9bf451c088a40c1b744fa91..bf9f9f69d3472c8b10f874a9507a344434aec085 100644
--- a/tests/src/Kernel/ConfigEntityTest.php
+++ b/tests/src/Kernel/ConfigEntityTest.php
@@ -52,6 +52,10 @@ class ConfigEntityTest extends RulesKernelTestBase {
     ])->setExpression($action);
     $config_entity->save();
 
+    // The logger instance has changed, refresh it.
+    $this->logger = $this->container->get('logger.channel.rules_debug');
+    $this->logger->addLogger($this->debugLog);
+
     $loaded_entity = $this->storage->load('test_rule');
     $this->assertEquals($action->getConfiguration(), $loaded_entity->get('component')['expression'], 'Action configuration is the same after loading the config.');
 
@@ -68,8 +72,7 @@ class ConfigEntityTest extends RulesKernelTestBase {
    */
   public function testConfigRule() {
     // Create a simple rule with one action and one condition.
-    $rule = $this->expressionManager
-      ->createRule();
+    $rule = $this->expressionManager->createRule();
     $rule->addCondition('rules_test_true');
     $rule->addAction('rules_test_debug_log');
 
diff --git a/tests/src/Kernel/ConfigurableEventHandlerTest.php b/tests/src/Kernel/ConfigurableEventHandlerTest.php
index 2c348382e0271490faa481622598fa5a87dc519c..771b5f7726b61e37f8d26c65decee37f7eb88db3 100644
--- a/tests/src/Kernel/ConfigurableEventHandlerTest.php
+++ b/tests/src/Kernel/ConfigurableEventHandlerTest.php
@@ -112,6 +112,7 @@ class ConfigurableEventHandlerTest extends RulesKernelTestBase {
 
     // The logger instance has changed, refresh it.
     $this->logger = $this->container->get('logger.channel.rules_debug');
+    $this->logger->addLogger($this->debugLog);
 
     // Add node.field_integer.0.value to rules log message, read result.
     $this->node->field_integer->setValue(['0' => 11, '1' => 22]);
diff --git a/tests/src/Kernel/EventIntegrationTest.php b/tests/src/Kernel/EventIntegrationTest.php
index 4fce03747ac569565a5e581d45e6b46d3feca331..468d23932e08c6380ea1fecf5bd1fdf65f8819b8 100644
--- a/tests/src/Kernel/EventIntegrationTest.php
+++ b/tests/src/Kernel/EventIntegrationTest.php
@@ -64,6 +64,7 @@ class EventIntegrationTest extends RulesKernelTestBase {
 
     // The logger instance has changed, refresh it.
     $this->logger = $this->container->get('logger.channel.rules_debug');
+    $this->logger->addLogger($this->debugLog);
 
     $account = User::create(['name' => 'test_user']);
     // Invoke the hook manually which should trigger the rule.
@@ -90,6 +91,7 @@ class EventIntegrationTest extends RulesKernelTestBase {
 
     // The logger instance has changed, refresh it.
     $this->logger = $this->container->get('logger.channel.rules_debug');
+    $this->logger->addLogger($this->debugLog);
 
     $account = $this->container->get('current_user');
     // Invoke the hook manually which should trigger the rule.
@@ -116,6 +118,7 @@ class EventIntegrationTest extends RulesKernelTestBase {
 
     // The logger instance has changed, refresh it.
     $this->logger = $this->container->get('logger.channel.rules_debug');
+    $this->logger->addLogger($this->debugLog);
 
     // Run cron.
     $this->container->get('cron')->run();
@@ -125,7 +128,7 @@ class EventIntegrationTest extends RulesKernelTestBase {
   }
 
   /**
-   * Test that a Logger message trigger the Rules debug logger listener.
+   * Test that a Logger message triggers the Rules debug logger listener.
    */
   public function testSystemLoggerEvent() {
     $rule = $this->expressionManager->createRule();
@@ -141,6 +144,7 @@ class EventIntegrationTest extends RulesKernelTestBase {
 
     // The logger instance has changed, refresh it.
     $this->logger = $this->container->get('logger.channel.rules_debug');
+    $this->logger->addLogger($this->debugLog);
 
     // Creates a logger-item, that must be dispatched as event.
     $this->container->get('logger.factory')->get('rules_test')
@@ -167,6 +171,7 @@ class EventIntegrationTest extends RulesKernelTestBase {
 
     // The logger instance has changed, refresh it.
     $this->logger = $this->container->get('logger.channel.rules_debug');
+    $this->logger->addLogger($this->debugLog);
 
     $dispatcher = $this->container->get('event_dispatcher');
 
@@ -201,6 +206,7 @@ class EventIntegrationTest extends RulesKernelTestBase {
 
     // The logger instance has changed, refresh it.
     $this->logger = $this->container->get('logger.channel.rules_debug');
+    $this->logger->addLogger($this->debugLog);
 
     $dispatcher = $this->container->get('event_dispatcher');
 
@@ -238,6 +244,7 @@ class EventIntegrationTest extends RulesKernelTestBase {
 
     // The logger instance has changed, refresh it.
     $this->logger = $this->container->get('logger.channel.rules_debug');
+    $this->logger->addLogger($this->debugLog);
 
     $account = User::create(['name' => 'test_user']);
     // Invoke the hook manually which should trigger the rules_user_login event.
@@ -295,6 +302,7 @@ class EventIntegrationTest extends RulesKernelTestBase {
 
     // The logger instance has changed, refresh it.
     $this->logger = $this->container->get('logger.channel.rules_debug');
+    $this->logger->addLogger($this->debugLog);
 
     // Now change the title and trigger the presave event by savoing the node.
     $node->setTitle('new title');
diff --git a/tests/src/Kernel/RulesKernelTestBase.php b/tests/src/Kernel/RulesKernelTestBase.php
index aca1c7cd40e84bd86fcfc5a0f30c1caa57739cb7..e7b303c12c8ec4bae233e635166e0ec594e0febe 100644
--- a/tests/src/Kernel/RulesKernelTestBase.php
+++ b/tests/src/Kernel/RulesKernelTestBase.php
@@ -37,6 +37,13 @@ abstract class RulesKernelTestBase extends KernelTestBase {
    */
   protected $logger;
 
+  /**
+   * Rules debug log.
+   *
+   * @var \Drupal\rules\Logger\RulesDebugLog
+   */
+  protected $debugLog;
+
   /**
    * The messenger service.
    *
@@ -71,6 +78,7 @@ abstract class RulesKernelTestBase extends KernelTestBase {
     parent::setUp();
 
     $this->logger = $this->container->get('logger.channel.rules_debug');
+    $this->debugLog = $this->container->get('logger.rules_debug_log');
 
     // Turn on debug logging, set error level to collect only errors. This way
     // we can ignore the normal Rules debug messages that would otherwise get
@@ -114,7 +122,7 @@ abstract class RulesKernelTestBase extends KernelTestBase {
    */
   protected function assertRulesDebugLogEntryExists($message, $log_item_index = 0) {
     // Test that the action has logged something.
-    $logs = $this->logger->getLogs();
+    $logs = $this->debugLog->getLogs();
     $this->assertEquals($logs[$log_item_index]['message'], $message);
   }
 
diff --git a/tests/src/Unit/RulesDebugLoggerChannelTest.php b/tests/src/Unit/RulesDebugLoggerChannelTest.php
index b5da4755aa15e7de9cf41844cb865cf5ac4786b8..48cdc617f5e987fe08319aae36bbe724774a949c 100644
--- a/tests/src/Unit/RulesDebugLoggerChannelTest.php
+++ b/tests/src/Unit/RulesDebugLoggerChannelTest.php
@@ -3,9 +3,11 @@
 namespace Drupal\Tests\rules\Unit;
 
 use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\Core\Logger\LoggerChannelInterface;
 use Drupal\Core\Logger\RfcLogLevel;
-use Drupal\rules\Logger\RulesDebugLoggerChannel;
 use Drupal\Tests\UnitTestCase;
+use Drupal\rules\Logger\RulesDebugLog;
+use Drupal\rules\Logger\RulesDebugLoggerChannel;
 use Prophecy\Argument;
 use Psr\Log\LoggerInterface;
 use Psr\Log\LogLevel;
@@ -24,18 +26,25 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
   protected $container;
 
   /**
-   * The Rules logger.channel.rules service.
+   * The session service.
    *
-   * @var \Psr\Log\LoggerInterface
+   * @var \Symfony\Component\HttpFoundation\Session\SessionInterface
+   */
+  protected $session;
+
+  /**
+   * The Rules logger.channel.rules_debug service.
+   *
+   * @var \Psr\Log\LoggerChannelInterface
    */
-  protected $rulesLogger;
+  protected $rulesDebugLogger;
 
   /**
-   * The messenger service.
+   * The Rules logger.rules_debug_log service.
    *
-   * @var \Drupal\Core\Messenger\MessengerInterface
+   * @var \Psr\Log\LoggerInterface
    */
-  protected $messenger;
+  protected $rulesDebugLog;
 
   /**
    * {@inheritdoc}
@@ -43,10 +52,13 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
   protected function setUp() {
     parent::setUp();
     $container = new ContainerBuilder();
-    $this->rulesLogger = $this->prophesize(LoggerInterface::class)->reveal();
-    $container->set('logger.channel.rules', $this->rulesLogger);
-    $this->messenger = new TestMessenger();
-    $container->set('messenger', $this->messenger);
+    $this->rulesDebugLogger = $this->prophesize(LoggerChannelInterface::class)->reveal();
+    $container->set('logger.channel.rules_debug', $this->rulesDebugLogger);
+    $this->session = new TestSession();
+    $container->set('session', $this->session);
+
+    $this->rulesDebugLog = new RulesDebugLog($this->session);
+    $container->set('logger.rules_debug_log', $this->rulesDebugLog);
     \Drupal::setContainer($container);
     $this->container = $container;
   }
@@ -58,16 +70,16 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
    *   Expected PSR3 log level.
    * @param int $rfc_message_level
    *   Expected RFC 5424 log level.
-   * @param int $log
-   *   Is system logging enabled.
-   * @param int $debug_screen
-   *   Is screen logging enabled.
+   * @param bool $system_debug
+   *   Is system debug logging enabled.
+   * @param bool $debug_log_enabled
+   *   Is debug logging enabled.
    * @param string $psr3_log_error_level
    *   Minimum required PSR3 log level at which to log.
    * @param int $expect_system_log
-   *   Amount of logs to be created.
+   *   Number of logs expected to be created.
    * @param int $expect_screen_log
-   *   Amount of messages to be created.
+   *   Number of messages expected to be created.
    * @param string $message
    *   Log message.
    *
@@ -75,8 +87,9 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
    *
    * @covers ::log
    */
-  public function testLog($psr3_message_level, $rfc_message_level, $log, $debug_screen, $psr3_log_error_level, $expect_system_log, $expect_screen_log, $message) {
-    $this->clearMessages();
+  public function testLog($psr3_message_level, $rfc_message_level, $system_debug, $debug_log_enabled, $psr3_log_error_level, $expect_system_log, $expect_screen_log, $message) {
+    // Clean up after previous test.
+    $this->rulesDebugLog->clearLogs();
 
     $config = $this->getConfigFactoryStub([
       'rules.settings' => [
@@ -84,48 +97,46 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
           'log_level' => $psr3_log_error_level,
         ],
         'debug_log' => [
-          'enabled' => $debug_screen,
-          'system_debug' => $log,
+          'enabled' => $debug_log_enabled,
+          'system_debug' => $system_debug,
           'log_level' => $psr3_log_error_level,
         ],
       ],
     ]);
-    $channel = new RulesDebugLoggerChannel($this->rulesLogger, $config, $this->messenger);
-    $logger = $this->prophesize(LoggerInterface::class);
-    $logger->log($rfc_message_level, $message, Argument::type('array'))
-      ->shouldBeCalledTimes($expect_system_log);
 
-    $channel->addLogger($logger->reveal());
+    $channel = new RulesDebugLoggerChannel($this->rulesDebugLog, $config);
+    $addedLogger = $this->prophesize(LoggerInterface::class);
+    $addedLogger->log($rfc_message_level, $message, Argument::type('array'))
+      ->shouldBeCalledTimes($expect_screen_log);
 
-    $channel->log($psr3_message_level, $message);
+    $channel->addLogger($addedLogger->reveal());
+    $channel->log($psr3_message_level, $message, []);
 
-    $messages = $this->messenger->all();
+    $messages = $this->rulesDebugLog->getLogs();
     if ($expect_screen_log > 0) {
       $this->assertNotNull($messages);
-      $this->assertArrayEquals([$psr3_message_level => [$message]], $messages);
-    }
-    else {
-      $this->assertNull($messages);
-    }
-  }
-
-  /**
-   * Clears the statically stored messages.
-   *
-   * @param null|string $type
-   *   (optional) The type of messages to clear. Defaults to NULL which causes
-   *   all messages to be cleared.
-   *
-   * @return $this
-   */
-  protected function clearMessages($type = NULL) {
-    if (isset($type)) {
-      $this->messenger->deleteByType($type);
+      $context = [
+        'channel' => 'rules_debug',
+        'link' => '',
+        'element' => NULL,
+        'scope' => NULL,
+        'path' => NULL,
+      ];
+      $context += $messages[0]['context'];
+      $this->assertArrayEquals([
+        0 => [
+          'message' => $message,
+          'context' => $context,
+          'level' => $psr3_message_level,
+          'timestamp' => $context['timestamp'],
+          'scope' => NULL,
+          'path' => NULL,
+        ],
+      ], $messages, "actual =" . var_export($messages, TRUE));
     }
     else {
-      $this->messenger->deleteAll();
+      $this->assertCount(0, $messages);
     }
-    return $this;
   }
 
   /**
@@ -136,8 +147,8 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
       [
         'psr3_message_level' => LogLevel::DEBUG,
         'rfc_message_level' => RfcLogLevel::DEBUG,
-        'system_log_enabled' => 0,
-        'screen_log_enabled' => 0,
+        'system_debug_enabled' => FALSE,
+        'debug_log_enabled' => FALSE,
         'min_psr3_level' => LogLevel::DEBUG,
         'expected_system_logs' => 0,
         'expected_screen_logs' => 0,
@@ -146,8 +157,8 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
       [
         'psr3_message_level' => LogLevel::DEBUG,
         'rfc_message_level' => RfcLogLevel::DEBUG,
-        'system_log_enabled' => 0,
-        'screen_log_enabled' => 1,
+        'system_debug_enabled' => FALSE,
+        'debug_log_enabled' => TRUE,
         'min_psr3_level' => LogLevel::DEBUG,
         'expected_system_logs' => 0,
         'expected_screen_logs' => 1,
@@ -156,8 +167,8 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
       [
         'psr3_message_level' => LogLevel::CRITICAL,
         'rfc_message_level' => RfcLogLevel::CRITICAL,
-        'system_log_enabled' => 1,
-        'screen_log_enabled' => 0,
+        'system_debug_enabled' => TRUE,
+        'debug_log_enabled' => FALSE,
         'min_psr3_level' => LogLevel::DEBUG,
         'expected_system_logs' => 1,
         'expected_screen_logs' => 0,
@@ -166,8 +177,8 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
       [
         'psr3_message_level' => LogLevel::CRITICAL,
         'rfc_message_level' => RfcLogLevel::CRITICAL,
-        'system_log_enabled' => 1,
-        'screen_log_enabled' => 1,
+        'system_debug_enabled' => TRUE,
+        'debug_log_enabled' => TRUE,
         'min_psr3_level' => LogLevel::DEBUG,
         'expected_system_logs' => 1,
         'expected_screen_logs' => 1,
@@ -176,8 +187,8 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
       [
         'psr3_message_level' => LogLevel::CRITICAL,
         'rfc_message_level' => RfcLogLevel::CRITICAL,
-        'system_log_enabled' => 1,
-        'screen_log_enabled' => 0,
+        'system_debug_enabled' => TRUE,
+        'debug_log_enabled' => FALSE,
         'min_psr3_level' => LogLevel::DEBUG,
         'expected_system_logs' => 1,
         'expected_screen_logs' => 0,
@@ -186,8 +197,8 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
       [
         'psr3_message_level' => LogLevel::CRITICAL,
         'rfc_message_level' => RfcLogLevel::CRITICAL,
-        'system_log_enabled' => 1,
-        'screen_log_enabled' => 1,
+        'system_debug_enabled' => TRUE,
+        'debug_log_enabled' => TRUE,
         'min_psr3_level' => LogLevel::DEBUG,
         'expected_system_logs' => 1,
         'expected_screen_logs' => 1,
@@ -196,8 +207,8 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
       [
         'psr3_message_level' => LogLevel::INFO,
         'rfc_message_level' => RfcLogLevel::INFO,
-        'system_log_enabled' => 1,
-        'screen_log_enabled' => 0,
+        'system_debug_enabled' => TRUE,
+        'debug_log_enabled' => FALSE,
         'min_psr3_level' => LogLevel::CRITICAL,
         'expected_system_logs' => 0,
         'expected_screen_logs' => 0,
@@ -206,8 +217,8 @@ class RulesDebugLoggerChannelTest extends UnitTestCase {
       [
         'psr3_message_level' => LogLevel::INFO,
         'rfc_message_level' => RfcLogLevel::INFO,
-        'system_log_enabled' => 1,
-        'screen_log_enabled' => 1,
+        'system_debug_enabled' => TRUE,
+        'debug_log_enabled' => TRUE,
         'min_psr3_level' => LogLevel::CRITICAL,
         'expected_system_logs' => 0,
         'expected_screen_logs' => 0,
diff --git a/tests/src/Unit/TestSession.php b/tests/src/Unit/TestSession.php
new file mode 100644
index 0000000000000000000000000000000000000000..ec41c57a096f6b4b15b99857af43951495ea34b3
--- /dev/null
+++ b/tests/src/Unit/TestSession.php
@@ -0,0 +1,149 @@
+<?php
+
+namespace Drupal\Tests\rules\Unit;
+
+use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
+use Symfony\Component\HttpFoundation\Session\SessionInterface;
+
+/**
+ * Implements just the methods we need for the Rules unit tests.
+ */
+class TestSession implements SessionInterface {
+
+  /**
+   * Simulated session storage.
+   *
+   * @var array
+   */
+  protected $logs = [];
+
+  /**
+   * {@inheritdoc}
+   */
+  public function all() {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function clear() {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function get($key, $default = NULL) {
+    if (isset($this->logs[$key])) {
+      return $this->logs[$key];
+    }
+    else {
+      return $default;
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getBag($name) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getId() {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getMetadataBag() {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getName() {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function has($name) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function invalidate($lifetime = NULL) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isStarted() {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function migrate($destroy = FALSE, $lifetime = NULL) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function registerBag(SessionBagInterface $bag) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function remove($key) {
+    if (isset($this->logs[$key])) {
+      $return = $this->logs[$key];
+      unset($this->logs[$key]);
+      return $return;
+    }
+    else {
+      return NULL;
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function replace(array $attributes) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function save() {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function set($key, $value) {
+    $this->logs[$key] = $value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setId($id) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setName($name) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function start() {
+  }
+
+}