diff --git a/includes/rules.core.inc b/includes/rules.core.inc
index 2f43ddf..8e4d72c 100644
--- a/includes/rules.core.inc
+++ b/includes/rules.core.inc
@@ -2201,7 +2201,9 @@ class RulesLog {
     $line = 0;
     $output = array();
     while (isset($this->log[$line])) {
-      $output[] = $this->renderHelper($line);
+      $vars['head'] = t($this->log[$line][0], $this->log[$line][1]);
+      $vars['log'] = $this->renderHelper($line);
+      $output[] = theme('rules_debug_element', $vars);
       $line++;
     }
     return implode('', $output);
@@ -2216,7 +2218,9 @@ class RulesLog {
     while ($line < count($this->log)) {
       if ($output && !empty($this->log[$line][4])) {
         // The next entry stems from another evaluated set, add in its log messages here
-        $output[] = $this->renderHelper($line);
+        $vars['head'] = t($this->log[$line][0], $this->log[$line][1]);
+        $vars['log'] = $this->renderHelper($line);
+        $output[] = theme('rules_debug_element', $vars);
       }
       else {
         $formatted_diff = round(($this->log[$line][3] - $startTime) * 1000, 3) .' ms';
diff --git a/rules.module b/rules.module
index 0a6b27f..1c6f0b9 100644
--- a/rules.module
+++ b/rules.module
@@ -877,6 +877,10 @@ function rules_theme() {
       'render element' => 'element',
       'file' => 'ui/ui.theme.inc',
     ),
+    'rules_debug_element' => array(
+      'render element' => 'element',
+      'file' => 'ui/ui.theme.inc',
+    ),
   );
 }
 
@@ -893,6 +897,9 @@ function rules_permission() {
       'description' => t('Use any data property, Rules action or input evaluation system regardless of permission restrictions.'),
       'restrict access' => TRUE,
     ),
+    'access rules debug' => array(
+      'title' => t('Access the Rules debug log'),
+    ),
   );
 }
 
@@ -938,6 +945,16 @@ function rules_menu_add_element_title($array) {
 }
 
 /**
+ * Returns the current region for the debug log.
+ */
+function rules_debug_log_region() {
+  // If there is no setting for the current theme use the default theme setting.
+  global $theme_key;
+  $theme_default = variable_get('theme_default', 'bartik');
+  return variable_get('rules_debug_region_' . $theme_key, variable_get('rules_debug_region_' . $theme_default, 'help'));
+}
+
+/**
  * Implements hook_page_build() to add the rules debug log to the page bottom.
  */
 function rules_page_build(&$page) {
@@ -949,7 +966,7 @@ function rules_page_build(&$page) {
   }
 
   if (isset($_SESSION['rules_debug'])) {
-    $region = variable_get('rules_debug_region', 'help');
+    $region = rules_debug_log_region();
     foreach ($_SESSION['rules_debug'] as $log) {
       $page[$region]['rules_debug'][] = array(
         '#markup' => $log,
@@ -958,17 +975,25 @@ function rules_page_build(&$page) {
     }
     unset($_SESSION['rules_debug']);
   }
+
   if (rules_show_debug_output()) {
+    $region = rules_debug_log_region();
+    $page[$region]['rules_debug']['#pre_render'] = array('rules_debug_log_pre_render');
+  }
+}
+
+/**
+ * Pre-render callback for the debug log, which renders and then clears it.
+ */
+function rules_debug_log_pre_render($elements) {
+  $logger = RulesLog::logger();
+  if ($log = $logger->render()) {
     $logger = RulesLog::logger();
-    $region = variable_get('rules_debug_region', 'help');
-    if ($log = $logger->render()) {
-      $page[$region]['rules_debug'][] = array(
-        '#markup' => $log,
-      );
-      $page[$region]['rules_debug']['#theme_wrappers'] = array('rules_log');
-      $logger->clear();
-    }
+    $logger->clear();
+    $elements[] = array('#markup' => $log);
+    $elements['#theme_wrappers'] = array('rules_log');
   }
+  return $elements;
 }
 
 /**
@@ -995,8 +1020,11 @@ function rules_drupal_goto_alter(&$path, &$options, &$http_response_code) {
  * Returns whether the debug log should be shown.
  */
 function rules_show_debug_output() {
+  if (variable_get('rules_debug', FALSE) && user_access('access rules debug')) {
+    return TRUE;
+  }
   // For performance avoid unnecessary auto-loading of the RulesLog class.
-  return variable_get('rules_debug', FALSE) || (class_exists('RulesLog', FALSE) && RulesLog::logger()->hasErrors() && user_access('administer rules'));
+  return (class_exists('RulesLog', FALSE) && RulesLog::logger()->hasErrors() && user_access('administer rules'));
 }
 
 /**
diff --git a/rules_admin/rules_admin.inc b/rules_admin/rules_admin.inc
index 77d91a4..2d5e236 100644
--- a/rules_admin/rules_admin.inc
+++ b/rules_admin/rules_admin.inc
@@ -133,12 +133,48 @@ function rules_admin_components_overview($form, &$form_state, $base_path) {
  * Rules settings form.
  */
 function rules_admin_settings($form, &$form_state) {
-  $form['rules_debug'] = array(
+  $link = t('Access the Rules debug log');
+  $form['rules_debug_log'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Debug log settings'),
+    '#description' => t('Once the debug log is enabled, it appears every time a rule is evaluated. It is only visible for users having the permission <a href="!url">%link</a>.', array('%link' => $link, '!url' => url('admin/people/permissions', array('fragment' => 'module-rules')))),
+    '#collapsible' => FALSE,
+  );
+  $form['rules_debug_log']['rules_debug'] = array(
     '#type' => 'checkbox',
     '#title' => t('Debug rules evaluation'),
     '#default_value' => variable_get('rules_debug', FALSE),
     '#description' => t('If activated debugging information is shown when rules are evaluated.'),
   );
+
+  $form['rules_debug_log']['regions'] = array(
+    '#type' => 'container',
+    '#states' => array(
+      // Hide the regions settings when the debug log is disabled.
+      'invisible' => array(
+        'input[name="rules_debug"]' => array('checked' => FALSE),
+      ),
+    ),
+  );
+
+  $theme_default = variable_get('theme_default', 'bartik');
+  $admin_theme = variable_get('admin_theme', 'seven');
+
+  $form['rules_debug_log']['regions']['rules_debug_region_' . $theme_default] = array(
+    '#type' => 'select',
+    '#title' => t('Default theme region'),
+    '#description' => t("The region, where the debug log should be displayed on the default theme %theme. For other themes, Rules will try to display the log on the same region, or hide it in case it doesn't exist.", array('%theme' => $theme_default)),
+    '#options' => system_region_list($theme_default, REGIONS_VISIBLE),
+    '#default_value' => variable_get('rules_debug_region_' . $theme_default, 'help'),
+  );
+
+  $form['rules_debug_log']['regions']['rules_debug_region_' . $admin_theme] = array(
+    '#type' => 'select',
+    '#title' => t('Admin theme region'),
+    '#description' => t('The region, where the debug log should be displayed on the admin theme %theme.', array('%theme' => $admin_theme)),
+    '#options' => system_region_list($admin_theme, REGIONS_VISIBLE),
+    '#default_value' => variable_get('rules_debug_region_' . $admin_theme, 'help'),
+  );
   if (db_table_exists('rules_rules')) {
     drupal_set_message(t('There are left over rule configurations from a previous Rules 1.x installation. Proceed to the <a href="!url">upgrade page</a> to convert them and consult the README.txt for more details.', array('!url' => url('admin/config/workflow/rules/upgrade'))), 'warning');
   }
diff --git a/ui/rules.debug.js b/ui/rules.debug.js
new file mode 100644
index 0000000..f337bdc
--- /dev/null
+++ b/ui/rules.debug.js
@@ -0,0 +1,68 @@
+/**
+ * @file
+ * Adds the collapsible functionality to the rules debug log.
+ */
+
+// Registers the rules namespace.
+Drupal.rules = Drupal.rules || {};
+
+(function($) {
+  Drupal.behaviors.rules_debug_log = {
+    attach: function(context) {
+      $('.rules-debug-open').click(function () {
+        var icon = $(this).children('span.ui-icon');
+        if ($(this).next().is(':hidden')) {
+          Drupal.rules.changeDebugIcon(icon, true);
+        }
+        else {
+          Drupal.rules.changeDebugIcon(icon, false);
+        }
+        $(this).next().toggle();
+      }).next().hide();
+
+      $('.rules-debug-open-main').click(function () {
+        var icon = $(this).children('span.ui-icon');
+        if ($(this).parent().next().is(':hidden')) {
+          Drupal.rules.changeDebugIcon(icon, true);
+          $(this).parent().children('.rules-debug-open-all').text(Drupal.t('-Close all-'));
+        }
+        else {
+          Drupal.rules.changeDebugIcon(icon, false);
+          $(this).parent().children('.rules-debug-open-all').text(Drupal.t('-Open all-'));
+        }
+        $(this).parent().next().toggle();
+      }).parent().next().hide();
+
+      $('.rules-debug-open-all').click(function() {
+        if ($('.rules-debug-open-main').parent().next().is(':hidden')) {
+          $('.rules-debug-open').next().show();
+          Drupal.rules.changeDebugIcon($('.rules-debug-open').children('span.ui-icon'), true);
+          $('.rules-debug-open-main').parent().next().show();
+          Drupal.rules.changeDebugIcon($(this).prev().children('span.ui-icon'), true);
+          $(this).text(Drupal.t('-Close all-'));
+        }
+        else {
+          $('.rules-debug-open-main').parent().next().hide();
+          Drupal.rules.changeDebugIcon($('.rules-debug-open-main').children('span.ui-icon'), false);
+          $(this).text(Drupal.t('-Open all-'));
+          $('.rules-debug-open').next().hide();
+          Drupal.rules.changeDebugIcon($(this).prev().children('span.ui-icon'), false);
+        }
+      });
+    }
+  };
+
+  /**
+   * Changes the icon of a collapsible div.
+   */
+  Drupal.rules.changeDebugIcon = function(item, open) {
+    if (open == true) {
+      item.removeClass('ui-icon-triangle-1-e');
+      item.addClass('ui-icon-triangle-1-s');
+    }
+    else {
+      item.removeClass('ui-icon-triangle-1-s');
+      item.addClass('ui-icon-triangle-1-e');
+    }
+  }
+})(jQuery);
diff --git a/ui/rules.ui.css b/ui/rules.ui.css
index 528bb70..c0d2778 100755
--- a/ui/rules.ui.css
+++ b/ui/rules.ui.css
@@ -70,11 +70,44 @@ ul.rules-operations-add li {
 }
 
 .rules-debug-log {
+  font: 81.3% "Lucida Grande","Lucida Sans Unicode",sans-serif;
   background-color: #eeeeee;
   border: 1px solid #cccccc;
-  font-color: #333333;
+  color: #333333;
   padding: 5px;
-  margin: 2em;
+  margin: 1.5em 0em;
+}
+
+.rules-debug-collapsible-link {
+  position: relative;
+  cursor: pointer;
+
+  /* The span element with the icon which opens the log, has a whitepsace.
+     Since we don't want the user to mark this white space, we prevent this
+     using the this code.*/
+  -moz-user-select: -moz-none;
+  -khtml-user-select: none;
+  -webkit-user-select: none;
+  -o-user-select: none;
+  user-select: none;
+}
+
+.rules-debug-log-head {
+  font-weight: bold;
+}
+
+div.rules-debug-log-head {
+  margin: 0.5em 0em;
+}
+
+.rules-debug-icon-open {
+  position: relative;
+  float: left;
+}
+
+.rules-debug-open-all {
+  position: relative;
+  float: right;
 }
 
 .rules-debug-log ul {
diff --git a/ui/ui.theme.inc b/ui/ui.theme.inc
index 19f5d55..e488fe1 100755
--- a/ui/ui.theme.inc
+++ b/ui/ui.theme.inc
@@ -204,11 +204,26 @@ function theme_rules_data_selector_help($variables) {
 function theme_rules_log($variables) {
   $element = $variables['element'];
   drupal_add_css(drupal_get_path('module', 'rules') . '/ui/rules.ui.css');
+  // Add jquery ui core css and functions, which are needed for the icons.
+  drupal_add_library('system', 'ui');
+  drupal_add_js(drupal_get_path('module', 'rules') . '/ui/rules.debug.js');
 
   $output = '<div class="rules-debug-log">';
-  $output .= '<h3>' . t('Rules evaluation log') . '</h3>';
+
+  $output .= '<h3 class="rules-debug-log-head">';
+  $output .= '<span class="rules-debug-open-main rules-debug-collapsible-link">';
+  $output .= '<span unselectable="on" class="ui-icon ui-icon-triangle-1-e rules-debug-icon-open">&nbsp;</span>';
+  $output .= t('Rules evaluation log');
+  $output .= '</span>';
+  $output .= '</span>';
+  $output .= '<span class="rules-debug-open-all rules-debug-collapsible-link">-' . t('Open all') . '-<span>';
+  $output .= '</h3>';
+
+  $output .= '<div>';
   $output .= $element['#children'];
   $output .= '</div>';
+  $output .= '</div>';
+
   return $output;
 }
 
@@ -241,3 +256,17 @@ function theme_rules_autocomplete($variables) {
 
   return $output;
 }
+
+/**
+ * Theme rules debug log elements.
+ */
+function theme_rules_debug_element($variables) {
+  $output = '<div class="rules-debug-block">';
+  $output .= '<div class="rules-debug-log-head rules-debug-open rules-debug-collapsible-link">"';
+  $output .= '<span unselectable="on" class="ui-icon ui-icon-triangle-1-e rules-debug-icon-open">&nbsp;</span>';
+  $output .= $variables['head'];
+  $output .= '</div>';
+  $output .= $variables['log'];
+  $output .= '</div>';
+  return $output;
+}
