diff --git a/contrib/openldap/core-fd-conf.schema b/contrib/openldap/core-fd-conf.schema
index 306ad80929923084f6866214dc3c886a7ccff7fe..32291dc1f04be61a5b19cdef3c28f4cf464c40d6 100644
--- a/contrib/openldap/core-fd-conf.schema
+++ b/contrib/openldap/core-fd-conf.schema
@@ -334,6 +334,12 @@ attributetype ( 1.3.6.1.4.1.38414.8.16.4 NAME 'fdDebugLevel'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
   SINGLE-VALUE)
 
+attributetype ( 1.3.6.1.4.1.38414.8.16.5 NAME 'fdDebugLogging'
+  DESC 'FusionDirectory - Debug logging'
+  EQUALITY booleanMatch
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
+  SINGLE-VALUE )
+
 # Snapshots
 
 attributetype ( 1.3.6.1.4.1.38414.8.17.1 NAME 'fdEnableSnapshots'
@@ -599,7 +605,7 @@ objectclass ( 1.3.6.1.4.1.38414.8.2.1 NAME 'fusionDirectoryConf'
     fdModificationDetectionAttribute $ fdLogging $ fdLdapSizeLimit $ fdWildcardForeignKeys $
     fdLoginAttribute $ fdForceSSL $ fdWarnSSL $ fdStoreFilterSettings $ fdSessionLifeTime $
     fdHttpAuthActivated $ fdHttpHeaderAuthActivated $ fdHttpHeaderAuthHeaderName $
-    fdDisplayErrors $ fdLdapMaxQueryTime $ fdLdapStats $ fdDebugLevel $
+    fdDisplayErrors $ fdLdapMaxQueryTime $ fdLdapStats $ fdDebugLevel $ fdDebugLogging $
     fdEnableSnapshots $ fdSnapshotBase $
     fdTabHook $ fdShells $ fdDefaultShell $ fdDisplayHookOutput $
     fdPluginsMenuBlacklist $ fdManagementConfig $ fdManagementUserConfig $
diff --git a/include/class_logging.inc b/include/class_logging.inc
index 93b2818aaab61968d7147131d337be0592ac534d..a3a111dbe087b5e45c8d7ea1d8525f74d9ab0e53 100644
--- a/include/class_logging.inc
+++ b/include/class_logging.inc
@@ -88,6 +88,66 @@ class logging
     }
   }
 
+  /*!
+   * \brief Debug output method
+   *
+   * Print a DEBUG level if specified debug level of the level matches the
+   * the configured debug level.
+   *
+   * \param int $level        The log level of the message (one of the DEBUG_* constants)
+   *
+   * \param int $line         Line of origin (using __LINE__ is common)
+   *
+   * \param string $function  Function of origin (using __FUNCTION__ is common)
+   *
+   * \param string $file      File of origin (using __FILE__ is common)
+   *
+   * \param mixed $data       Operation result. Can be a message or an array, which is printed with print_a.
+   *
+   * \param string $info      Operation description
+   */
+  static function debug (int $level, int $line, string $function, string $file, $data, string $info = '')
+  {
+    global $config;
+
+    static $first = TRUE;
+    if (($_SERVER['REQUEST_METHOD'] == 'POST') && preg_match('/index.php$/', $_SERVER['REQUEST_URI'])) {
+      return;
+    }
+
+    if (session::get('DEBUGLEVEL') & $level) {
+      if ($first) {
+        echo '<div id="debug-handling" class="notice">'.
+              '<img src="geticon.php?context=status&amp;icon=dialog-information&amp;size=22" alt="Information" style="vertical-align:middle;margin-right:.2em;"/>'.
+              'There is some debug output '.
+              '<button onClick="javascript:$$(\'div.debug_div\').each(function (a) { a.toggle(); });">Toggle</button>'.
+            '</div>';
+        $first = FALSE;
+      }
+      $output = "DEBUG[$level] ";
+      if ($function != '') {
+        $output .= "($file:$function():$line) - $info: ";
+      } else {
+        $output .= "($file:$line) - $info: ";
+      }
+      echo '<div class="debug_div">';
+      echo $output;
+      $logline = $output;
+      if (is_array($data)) {
+        print_a($data);
+        $logline .= print_r($data, TRUE);
+      } else {
+        echo "'$data'";
+        $logline .= "'$data'";
+      }
+      echo "</div>\n";
+
+      if (is_object($config) && preg_match('/true/i', $config->get_cfg_value('debugLogging', ''))) {
+        fusiondirectory_log($logline);
+      }
+    }
+  }
+
   /*!
    * \brief Check the options
    *
diff --git a/include/functions.inc b/include/functions.inc
index f305e99e5b99d089995de4fd6b4f1a616e17baf7..1da038c4851e95e8681bf1b7942505a8f37cb95c 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -172,34 +172,7 @@ function plugin_available ($plugin)
  */
 function DEBUG ($level, $line, $function, $file, $data, $info = '')
 {
-  static $first = TRUE;
-  if (($_SERVER['REQUEST_METHOD'] == 'POST') && preg_match('/index.php$/', $_SERVER['REQUEST_URI'])) {
-    return;
-  }
-  if (session::get('DEBUGLEVEL') & $level) {
-    if ($first) {
-      echo '<div id="debug-handling" class="notice">'.
-            '<img src="geticon.php?context=status&amp;icon=dialog-information&amp;size=22" alt="Information" style="vertical-align:middle;margin-right:.2em;"/>'.
-            'There is some debug output '.
-            '<button onClick="javascript:$$(\'div.debug_div\').each(function (a) { a.toggle(); });">Toggle</button>'.
-          '</div>';
-      $first = FALSE;
-    }
-    $output = "DEBUG[$level] ";
-    if ($function != '') {
-      $output .= "($file:$function():$line) - $info: ";
-    } else {
-      $output .= "($file:$line) - $info: ";
-    }
-    echo '<div class="debug_div">';
-    echo $output;
-    if (is_array($data)) {
-      print_a($data);
-    } else {
-      echo "'$data'";
-    }
-    echo "</div>\n";
-  }
+  logging::debug($level, $line, $function, $file, $data, $info);
 }
 
 /*!
diff --git a/plugins/config/class_configInLdap.inc b/plugins/config/class_configInLdap.inc
index d86e35d3343edb2f6eb941f5e0ea9a1c093781d3..c05a5aa03392c59e23a6d9465fcb075c8dd9a263 100644
--- a/plugins/config/class_configInLdap.inc
+++ b/plugins/config/class_configInLdap.inc
@@ -323,6 +323,11 @@ class configInLdap extends simplePlugin
                     'SESSION',      'ACL',      'SI',     'Mail']
             )
           ),
+          new BooleanAttribute(
+            _('Log debug messages'),
+            _('Sends debug output to syslog as well'),
+            'fdDebugLogging'
+          ),
         ]
       ],
       'miscellaneous' => [