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