]> granicus.if.org Git - apache/commitdiff
Merge r1784318 from trunk:
authorYann Ylavic <ylavic@apache.org>
Fri, 8 Sep 2017 10:17:21 +0000 (10:17 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 8 Sep 2017 10:17:21 +0000 (10:17 +0000)
 Support use of optional "tag" in syslog entries. Streamline the patch.
 PR 60525.

Submitted by: jim
Reviewed by: rpluem, jim, mrumph

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1807707 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
docs/manual/mod/core.xml
server/log.c

diff --git a/CHANGES b/CHANGES
index d025033ea6e055c386807b2134c81b827261cc4a..1570904225ae461b5b3aeb017ca2f6edc56cb7da 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.4.28
 
+  *) core/log: Support use of optional "tag" in syslog entries.
+     PR 60525. [Ben Rubson <ben.rubson gmail.com>, Jim Jagielski]
+
   *) mod_proxy: Fix ProxyAddHeaders merging.  [Joe Orton]
  
   *) core: Disallow multiple Listen on the same IP:port when listener buckets
diff --git a/STATUS b/STATUS
index 5aa89e34b88406a424d7460c726b86855e766a89..d1ce072c797314205adce6802f39a93e22c3716e 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -115,11 +115,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) core: Support use of optional "tag" in syslog entries. PR 60525.
-     trunk patch: http://svn.apache.org/r1784318
-     2.4.x patch: http://home.apache.org/~jim/patches/syslog-tag.patch
-     +1: rpluem, jim, mrumph
-
   *) mod_proxy_wstunnel fix PR 61142
      2.4.x patch: svn merge -c 1801594 ^/httpd/httpd/trunk .
      +1: jfclere, jim, covener
index 5af1ebd91dce6f6457eea5555ab018e886330630..b3c1fb3c20468a11601a343a5a7f789f90bd5489 100644 (file)
@@ -1516,7 +1516,7 @@ ErrorDocument 404 /cgi-bin/bad_urls.pl
 <directivesynopsis>
 <name>ErrorLog</name>
 <description>Location where the server will log errors</description>
-<syntax> ErrorLog <var>file-path</var>|syslog[:<var>facility</var>]</syntax>
+<syntax> ErrorLog <var>file-path</var>|syslog[:[<var>facility</var>][:<var>tag</var>]]</syntax>
 <default>ErrorLog logs/error_log (Unix) ErrorLog logs/error.log (Windows and OS/2)</default>
 <contextlist><context>server config</context><context>virtual host</context>
 </contextlist>
@@ -1549,10 +1549,15 @@ ErrorLog "|/usr/local/bin/httpd_errors"
     <var>facility</var> can be one of the names usually documented in
     syslog(1).  The facility is effectively global, and if it is changed
     in individual virtual hosts, the final facility specified affects the
-    entire server.</p>
+    entire server. Same rules apply for the syslog tag, which by default
+    uses the Apache binary name, <code>httpd</code> in most cases. You can
+    also override this by using the <code>syslog::<var>tag</var></code>
+    syntax.</p>
 
     <highlight language="config">
 ErrorLog syslog:user
+ErrorLog syslog:user:httpd.srv1
+ErrorLog syslog::httpd.srv2
     </highlight>
 
     <p>Additional modules can provide their own ErrorLog providers. The syntax
index bfec379d2a663b01ce0b65515d48a304e3d42b5c..22567a43af0b76cbb987e30553dee6ad64d49d4c 100644 (file)
@@ -398,16 +398,40 @@ static int open_error_log(server_rec *s, int is_main, apr_pool_t *p)
 #ifdef HAVE_SYSLOG
     else if (!strncasecmp(s->error_fname, "syslog", 6)) {
         if ((fname = strchr(s->error_fname, ':'))) {
+            /* s->error_fname could be [level]:[tag] (see #60525) */
+            const char *tag;
+            apr_size_t flen;
             const TRANS *fac;
 
             fname++;
-            for (fac = facilities; fac->t_name; fac++) {
-                if (!strcasecmp(fname, fac->t_name)) {
-                    openlog(ap_server_argv0, LOG_NDELAY|LOG_CONS|LOG_PID,
-                            fac->t_val);
-                    s->error_log = NULL;
-                    return OK;
+            tag = ap_strchr_c(fname, ':');
+            if (tag) {
+                flen = tag - fname;
+                tag++;
+                if (*tag == '\0') {
+                    tag = ap_server_argv0;
                 }
+            } else {
+                flen = strlen(fname);
+                tag = ap_server_argv0;
+            }
+            if (flen == 0) {
+                /* Was something like syslog::foobar */
+                openlog(tag, LOG_NDELAY|LOG_CONS|LOG_PID, LOG_LOCAL7);
+            } else {
+                for (fac = facilities; fac->t_name; fac++) {
+                    if (!strncasecmp(fname, fac->t_name, flen)) {
+                        openlog(tag, LOG_NDELAY|LOG_CONS|LOG_PID,
+                                fac->t_val);
+                        s->error_log = NULL;
+                        return OK;
+                    }
+                }
+                /* Huh? Invalid level name? */
+                ap_log_error(APLOG_MARK, APLOG_STARTUP, APR_EBADPATH, NULL, APLOGNO(10036)
+                             "%s: could not open syslog error log %s.",
+                              ap_server_argv0, fname);
+                return DONE;
             }
         }
         else {