576df0
diff --git a/modules/loggers/config.m4 b/modules/loggers/config.m4
576df0
index 762e773e94..0848d2e377 100644
576df0
--- a/modules/loggers/config.m4
576df0
+++ b/modules/loggers/config.m4
576df0
@@ -5,6 +5,8 @@ dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
576df0
 APACHE_MODPATH_INIT(loggers)
576df0
 	
576df0
 APACHE_MODULE(log_config, logging configuration.  You won't be able to log requests to the server without this module., , , yes)
576df0
+APR_ADDTO(MOD_LOG_CONFIG_LDADD, [$SYSTEMD_LIBS])
576df0
+
576df0
 APACHE_MODULE(log_debug, configurable debug logging, , , most)
576df0
 APACHE_MODULE(log_forensic, forensic logging)
576df0
 
576df0
diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c
576df0
index 996c09cf49..50a056a2f8 100644
576df0
--- a/modules/loggers/mod_log_config.c
576df0
+++ b/modules/loggers/mod_log_config.c
576df0
@@ -172,6 +172,10 @@
576df0
 #include <limits.h>
576df0
 #endif
576df0
 
576df0
+#ifdef HAVE_SYSTEMD
576df0
+#include <systemd/sd-journal.h>
576df0
+#endif
576df0
+
576df0
 #define DEFAULT_LOG_FORMAT "%h %l %u %t \"%r\" %>s %b"
576df0
 
576df0
 module AP_MODULE_DECLARE_DATA log_config_module;
576df0
@@ -1638,6 +1642,25 @@ static apr_status_t ap_default_log_writer( request_rec *r,
576df0
 
576df0
     return rv;
576df0
 }
576df0
+
576df0
+static apr_status_t wrap_journal_stream(apr_pool_t *p, apr_file_t **outfd,
576df0
+                                        int priority)
576df0
+{
576df0
+#ifdef HAVE_SYSTEMD
576df0
+    int fd;
576df0
+
576df0
+    fd = sd_journal_stream_fd("httpd", priority, 0);
576df0
+    if (fd < 0) return fd;
576df0
+
576df0
+    /* This is an AF_UNIX socket fd so is more pipe-like than
576df0
+     * file-like (the fd is neither seekable or readable), and use of
576df0
+     * apr_os_pipe_put_ex() allows cleanup registration. */
576df0
+    return apr_os_pipe_put_ex(outfd, &fd, 1, p);
576df0
+#else
576df0
+    return APR_ENOTIMPL;
576df0
+#endif
576df0
+}
576df0
+
576df0
 static void *ap_default_log_writer_init(apr_pool_t *p, server_rec *s,
576df0
                                         const char* name)
576df0
 {
576df0
@@ -1650,6 +1673,32 @@ static void *ap_default_log_writer_init(apr_pool_t *p, server_rec *s,
576df0
         }
576df0
         return ap_piped_log_write_fd(pl);
576df0
     }
576df0
+    else if (strncasecmp(name, "journald:", 9) == 0) {
576df0
+        int priority;
576df0
+        const char *err = ap_parse_log_level(name + 9, &priority);
576df0
+        apr_status_t rv;
576df0
+        apr_file_t *fd;
576df0
+
576df0
+        if (err == NULL && priority > LOG_DEBUG) {
576df0
+            err = "TRACE level debugging not supported with journald";
576df0
+        }
576df0
+
576df0
+        if (err) {
576df0
+            ap_log_error(APLOG_MARK, APLOG_ERR, APR_EBADPATH, s, 
576df0
+                         "invalid journald log priority name %s: %s",
576df0
+                         name, err);
576df0
+            return NULL;
576df0
+        }
576df0
+
576df0
+        rv = wrap_journal_stream(p, &fd, priority);
576df0
+        if (rv) {
576df0
+            ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, 
576df0
+                         "could not open journald log stream");
576df0
+            return NULL;
576df0
+        }
576df0
+
576df0
+        return fd;
576df0
+    }
576df0
     else {
576df0
         const char *fname = ap_server_root_relative(p, name);
576df0
         apr_file_t *fd;