]> granicus.if.org Git - apache/blobdiff - server/log.c
Merge r1741310, r1741461 from trunk:
[apache] / server / log.c
index 4b73a451086685e8bbe5c20df276c3647b6c1be0..bfec379d2a663b01ce0b65515d48a304e3d42b5c 100644 (file)
@@ -53,6 +53,7 @@
 #include "http_main.h"
 #include "util_time.h"
 #include "ap_mpm.h"
+#include "ap_listen.h"
 
 #if HAVE_GETTID
 #include <sys/syscall.h>
@@ -248,14 +249,14 @@ AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p,
     char *filename = ap_server_root_relative(p, fname);
     if (!filename) {
         ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT,
-                     APR_EBADPATH, NULL, "Invalid -E error log file %s",
+                     APR_EBADPATH, NULL, APLOGNO(00085) "Invalid -E error log file %s",
                      fname);
         return APR_EBADPATH;
     }
     if ((rc = apr_file_open(&stderr_file, filename,
                             APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE,
                             APR_OS_DEFAULT, p)) != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, APLOGNO(00086)
                      "%s: could not open error log file %s.",
                      ap_server_argv0, fname);
         return rc;
@@ -288,7 +289,7 @@ AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p,
         stderr_pool = NULL;
 
     if (rc != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_CRIT, rc, NULL,
+        ap_log_error(APLOG_MARK, APLOG_CRIT, rc, NULL, APLOGNO(00087)
                      "unable to replace stderr with error log file");
     }
     return rc;
@@ -297,7 +298,7 @@ AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p,
 static void log_child_errfn(apr_pool_t *pool, apr_status_t err,
                             const char *description)
 {
-    ap_log_error(APLOG_MARK, APLOG_ERR, err, NULL,
+    ap_log_error(APLOG_MARK, APLOG_ERR, err, NULL, APLOGNO(00088)
                  "%s", description);
 }
 
@@ -331,10 +332,8 @@ static int log_child(apr_pool_t *p, const char *progname,
         && ((rc = apr_procattr_child_errfn_set(procattr, log_child_errfn))
                 == APR_SUCCESS)) {
         char **args;
-        const char *pname;
 
         apr_tokenize_to_argv(progname, &args, p);
-        pname = apr_pstrdup(p, args[0]);
         procnew = (apr_proc_t *)apr_pcalloc(p, sizeof(*procnew));
 
         if (dummy_stderr) {
@@ -342,7 +341,7 @@ static int log_child(apr_pool_t *p, const char *progname,
                 rc = apr_procattr_child_err_set(procattr, errfile, NULL);
         }
 
-        rc = apr_proc_create(procnew, pname, (const char * const *)args,
+        rc = apr_proc_create(procnew, args[0], (const char * const *)args,
                              NULL, procattr, p);
 
         if (rc == APR_SUCCESS) {
@@ -387,7 +386,7 @@ static int open_error_log(server_rec *s, int is_main, apr_pool_t *p)
          * child inherits the parents stderr. */
         rc = log_child(p, fname, &dummy, cmdtype, is_main);
         if (rc != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
+            ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, APLOGNO(00089)
                          "Couldn't start ErrorLog process '%s'.",
                          s->error_fname + 1);
             return DONE;
@@ -421,7 +420,7 @@ static int open_error_log(server_rec *s, int is_main, apr_pool_t *p)
     else {
         fname = ap_server_root_relative(p, s->error_fname);
         if (!fname) {
-            ap_log_error(APLOG_MARK, APLOG_STARTUP, APR_EBADPATH, NULL,
+            ap_log_error(APLOG_MARK, APLOG_STARTUP, APR_EBADPATH, NULL, APLOGNO(00090)
                          "%s: Invalid error log path %s.",
                          ap_server_argv0, s->error_fname);
             return DONE;
@@ -429,7 +428,7 @@ static int open_error_log(server_rec *s, int is_main, apr_pool_t *p)
         if ((rc = apr_file_open(&s->error_log, fname,
                                APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE,
                                APR_OS_DEFAULT, p)) != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
+            ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, APLOGNO(00091)
                          "%s: could not open error log file %s.",
                          ap_server_argv0, fname);
             return DONE;
@@ -480,7 +479,7 @@ int ap_open_logs(apr_pool_t *pconf, apr_pool_t *p /* plog */,
         apr_file_flush(s_main->error_log);
         rv = apr_file_dup2(stderr_log, s_main->error_log, stderr_p);
         if (rv != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s_main,
+            ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s_main, APLOGNO(00092)
                          "unable to replace stderr with error_log");
         }
         else {
@@ -499,8 +498,8 @@ int ap_open_logs(apr_pool_t *pconf, apr_pool_t *p /* plog */,
              * as stdin. This in turn would prevent the piped logger from
              * exiting.
              */
-             apr_file_close(s_main->error_log);
-             s_main->error_log = stderr_log;
+            apr_file_close(s_main->error_log);
+            s_main->error_log = stderr_log;
         }
     }
     /* note that stderr may still need to be replaced with something
@@ -509,9 +508,16 @@ int ap_open_logs(apr_pool_t *pconf, apr_pool_t *p /* plog */,
      * XXX: This is BS - /dev/null is non-portable
      *      errno-as-apr_status_t is also non-portable
      */
-    if (replace_stderr && freopen("/dev/null", "w", stderr) == NULL) {
-        ap_log_error(APLOG_MARK, APLOG_CRIT, errno, s_main,
-                     "unable to replace stderr with /dev/null");
+
+#ifdef WIN32
+#define NULL_DEVICE "nul"
+#else
+#define NULL_DEVICE "/dev/null"
+#endif
+
+    if (replace_stderr && freopen(NULL_DEVICE, "w", stderr) == NULL) {
+        ap_log_error(APLOG_MARK, APLOG_CRIT, errno, s_main, APLOGNO(00093)
+                     "unable to replace stderr with %s", NULL_DEVICE);
     }
 
     for (virt = s_main->next; virt; virt = virt->next) {
@@ -562,11 +568,11 @@ static int log_remote_address(const ap_errorlog_info *info, const char *arg,
                               char *buf, int buflen)
 {
     if (info->r && !(arg && *arg == 'c'))
-        return apr_snprintf(buf, buflen, "%s:%d", info->r->client_ip,
-                            info->r->client_addr->port);
+        return apr_snprintf(buf, buflen, "%s:%d", info->r->useragent_ip,
+                            info->r->useragent_addr ? info->r->useragent_addr->port : 0);
     else if (info->c)
-        return apr_snprintf(buf, buflen, "%s:%d", info->c->peer_ip,
-                            info->c->peer_addr->port);
+        return apr_snprintf(buf, buflen, "%s:%d", info->c->client_ip,
+                            info->c->client_addr ? info->c->client_addr->port : 0);
     else
         return 0;
 }
@@ -619,7 +625,7 @@ static int log_ctime(const ap_errorlog_info *info, const char *arg,
     int time_len = buflen;
     int option = AP_CTIME_OPTION_NONE;
 
-    while(arg && *arg) {
+    while (arg && *arg) {
         switch (*arg) {
             case 'u':   option |= AP_CTIME_OPTION_USEC;
                         break;
@@ -962,18 +968,20 @@ static int do_errorlog_default(const ap_errorlog_info *info, char *buf,
     }
 
     /*
-     * client_ip/peer_ip can be client or backend server. If we have a scoreboard
-     * handle, it is likely a client.
+     * useragent_ip/client_ip can be client or backend server. If we have
+     * a scoreboard handle, it is likely a client.
      */
     if (info->r) {
         len += apr_snprintf(buf + len, buflen - len,
                             info->r->connection->sbh ? "[client %s:%d] " : "[remote %s:%d] ",
-                            info->r->client_ip, info->r->client_addr->port);
+                            info->r->useragent_ip,
+                            info->r->useragent_addr ? info->r->useragent_addr->port : 0);
     }
     else if (info->c) {
         len += apr_snprintf(buf + len, buflen - len,
                             info->c->sbh ? "[client %s:%d] " : "[remote %s:%d] ",
-                            info->c->peer_ip, info->c->peer_addr->port);
+                            info->c->client_ip,
+                            info->c->client_addr ? info->c->client_addr->port : 0);
     }
 
     /* the actual error message */
@@ -1013,6 +1021,7 @@ static int do_errorlog_format(apr_array_header_t *fmt, ap_errorlog_info *info,
     int skipping = 0;
     ap_errorlog_format_item *items = (ap_errorlog_format_item *)fmt->elts;
 
+    AP_DEBUG_ASSERT(fmt->nelts > 0);
     for (i = 0; i < fmt->nelts; ++i) {
         ap_errorlog_format_item *item = &items[i];
         if (item->flags & AP_ERRORLOG_FLAG_FIELD_SEP) {
@@ -1085,7 +1094,8 @@ static void write_logline(char *errstr, apr_size_t len, apr_file_t *logf,
     }
 #ifdef HAVE_SYSLOG
     else {
-        syslog(level < LOG_PRIMASK ? level : APLOG_DEBUG, "%s", errstr);
+        syslog(level < LOG_PRIMASK ? level : APLOG_DEBUG, "%.*s",
+               (int)len, errstr);
     }
 #endif
 }
@@ -1110,7 +1120,8 @@ static void log_error_core(const char *file, int line, int module_index,
     int done = 0;
     int line_number = 0;
 
-    if (r && r->connection) {
+    if (r) {
+        AP_DEBUG_ASSERT(r->connection != NULL);
         c = r->connection;
     }
 
@@ -1250,7 +1261,7 @@ static void log_error_core(const char *file, int line, int module_index,
          * prepare and log one line
          */
 
-        if (log_format) {
+        if (log_format && !info.startup) {
             len += do_errorlog_format(log_format, &info, errstr + len,
                                       MAX_STRING_LEN - len,
                                       &errstr_start, &errstr_end, fmt, args);
@@ -1260,8 +1271,7 @@ static void log_error_core(const char *file, int line, int module_index,
                                        &errstr_start, &errstr_end, fmt, args);
         }
 
-        if (!*errstr)
-        {
+        if (!*errstr) {
             /*
              * Don't log empty lines. This can happen with once-per-conn/req
              * info if an item with AP_ERRORLOG_FLAG_REQUIRED is NULL.
@@ -1284,6 +1294,21 @@ static void log_error_core(const char *file, int line, int module_index,
     }
 }
 
+/* For internal calls to log_error_core with self-composed arg lists */
+static void log_error_va_glue(const char *file, int line, int module_index,
+                              int level, apr_status_t status,
+                              const server_rec *s, const conn_rec *c,
+                              const request_rec *r, apr_pool_t *pool,
+                              const char *fmt, ...)
+{
+    va_list args;
+
+    va_start(args, fmt);
+    log_error_core(file, line, module_index, level, status, s, c, r, pool,
+                   fmt, args);
+    va_end(args);
+}
+
 AP_DECLARE(void) ap_log_error_(const char *file, int line, int module_index,
                                int level, apr_status_t status,
                                const server_rec *s, const char *fmt, ...)
@@ -1362,6 +1387,129 @@ AP_DECLARE(void) ap_log_cerror_(const char *file, int line, int module_index,
     va_end(args);
 }
 
+#define BYTES_LOGGED_PER_LINE 16
+#define LOG_BYTES_BUFFER_SIZE (BYTES_LOGGED_PER_LINE * 3 + 2)
+
+static void fmt_data(unsigned char *buf, const void *vdata, apr_size_t len, apr_size_t *off)
+{
+    const unsigned char *data = (const unsigned char *)vdata;
+    unsigned char *chars;
+    unsigned char *hex;
+    apr_size_t this_time = 0;
+
+    memset(buf, ' ', LOG_BYTES_BUFFER_SIZE - 1);
+    buf[LOG_BYTES_BUFFER_SIZE - 1] = '\0';
+    
+    chars = buf; /* start character dump here */
+    hex   = buf + BYTES_LOGGED_PER_LINE + 1; /* start hex dump here */
+    while (*off < len && this_time < BYTES_LOGGED_PER_LINE) {
+        unsigned char c = data[*off];
+
+        if (apr_isprint(c)
+            && c != '\\') {  /* backslash will be escaped later, which throws
+                              * off the formatting
+                              */
+            *chars = c;
+        }
+        else {
+            *chars = '.';
+        }
+
+        if ((c >> 4) >= 10) {
+            *hex = 'a' + ((c >> 4) - 10);
+        }
+        else {
+            *hex = '0' + (c >> 4);
+        }
+
+        if ((c & 0x0F) >= 10) {
+            *(hex + 1) = 'a' + ((c & 0x0F) - 10);
+        }
+        else {
+            *(hex + 1) = '0' + (c & 0x0F);
+        }
+
+        chars += 1;
+        hex += 2;
+        *off += 1;
+        ++this_time;
+    }
+}
+
+static void log_data_core(const char *file, int line, int module_index,
+                          int level, const server_rec *s,
+                          const conn_rec *c, const request_rec *r,
+                          const char *label, const void *data, apr_size_t len,
+                          unsigned int flags)
+{
+    unsigned char buf[LOG_BYTES_BUFFER_SIZE];
+    apr_size_t off;
+    char prefix[20];
+
+    if (!(flags & AP_LOG_DATA_SHOW_OFFSET)) {
+        prefix[0] = '\0';
+    }
+
+    if (len > 0xffff) { /* bug in caller? */
+        len = 0xffff;
+    }
+
+    if (label) {
+        log_error_va_glue(file, line, module_index, level, APR_SUCCESS, s,
+                          c, r, NULL, "%s (%" APR_SIZE_T_FMT " bytes)",
+                          label, len);
+    }
+
+    off = 0;
+    while (off < len) {
+        if (flags & AP_LOG_DATA_SHOW_OFFSET) {
+            apr_snprintf(prefix, sizeof prefix, "%04x: ", (unsigned int)off);
+        }
+        fmt_data(buf, data, len, &off);
+        log_error_va_glue(file, line, module_index, level, APR_SUCCESS, s,
+                          c, r, NULL, "%s%s", prefix, buf);
+    }
+}
+
+AP_DECLARE(void) ap_log_data_(const char *file, int line, 
+                              int module_index, int level,
+                              const server_rec *s, const char *label,
+                              const void *data, apr_size_t len,
+                              unsigned int flags)
+{
+    log_data_core(file, line, module_index, level, s, NULL, NULL, label,
+                  data, len, flags);
+}
+
+AP_DECLARE(void) ap_log_rdata_(const char *file, int line,
+                               int module_index, int level,
+                               const request_rec *r, const char *label,
+                               const void *data, apr_size_t len,
+                               unsigned int flags)
+{
+    log_data_core(file, line, module_index, level, r->server, NULL, r, label,
+                  data, len, flags);
+}
+
+AP_DECLARE(void) ap_log_cdata_(const char *file, int line,
+                               int module_index, int level,
+                               const conn_rec *c, const char *label,
+                               const void *data, apr_size_t len,
+                               unsigned int flags)
+{
+    log_data_core(file, line, module_index, level, c->base_server, c, NULL,
+                  label, data, len, flags);
+}
+
+AP_DECLARE(void) ap_log_csdata_(const char *file, int line, int module_index,
+                                int level, const conn_rec *c, const server_rec *s,
+                                const char *label, const void *data,
+                                apr_size_t len, unsigned int flags)
+{
+    log_data_core(file, line, module_index, level, s, c, NULL, label, data,
+                  len, flags);
+}
+
 AP_DECLARE(void) ap_log_command_line(apr_pool_t *plog, server_rec *s)
 {
     int i;
@@ -1385,10 +1533,19 @@ AP_DECLARE(void) ap_log_command_line(apr_pool_t *plog, server_rec *s)
             strcat(result, " ");
         }
     }
-    ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s,
+    ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, APLOGNO(00094)
                  "Command line: '%s'", result);
 }
 
+/* grab bag function to log commonly logged and shared info */
+AP_DECLARE(void) ap_log_mpm_common(server_rec *s)
+{
+    ap_log_error(APLOG_MARK, APLOG_DEBUG , 0, s, APLOGNO(02639)
+                 "Using SO_REUSEPORT: %s (%d)",
+                 ap_have_so_reuseport ? "yes" : "no",
+                 ap_num_listen_buckets);
+}
+
 AP_DECLARE(void) ap_remove_pid(apr_pool_t *p, const char *rel_fname)
 {
     apr_status_t rv;
@@ -1397,11 +1554,11 @@ AP_DECLARE(void) ap_remove_pid(apr_pool_t *p, const char *rel_fname)
     if (fname != NULL) {
         rv = apr_file_remove(fname, p);
         if (rv != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
+            ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, APLOGNO(00095)
                          "failed to remove PID file %s", fname);
         }
         else {
-            ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
+            ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, APLOGNO(00096)
                          "removed PID file %s (pid=%" APR_PID_T_FMT ")",
                          fname, getpid());
         }
@@ -1424,7 +1581,7 @@ AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *filename)
     fname = ap_server_root_relative(p, filename);
     if (!fname) {
         ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT, APR_EBADPATH,
-                     NULL, "Invalid PID file path %s, ignoring.", filename);
+                     NULL, APLOGNO(00097) "Invalid PID file path %s, ignoring.", filename);
         return;
     }
 
@@ -1438,7 +1595,7 @@ AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *filename)
          *      that may screw up scripts written to do something
          *      based on the last modification time of the pid file.
          */
-        ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, p,
+        ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, p, APLOGNO(00098)
                       "pid file %s overwritten -- Unclean "
                       "shutdown of previous Apache run?",
                       fname);
@@ -1448,9 +1605,9 @@ AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *filename)
                             APR_WRITE | APR_CREATE | APR_TRUNCATE,
                             APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD, p))
         != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00099)
                      "could not create %s", fname);
-        ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, APLOGNO(00100)
                      "%s: could not log pid to file %s",
                      ap_server_argv0, fname);
         exit(1);
@@ -1477,7 +1634,7 @@ AP_DECLARE(apr_status_t) ap_read_pid(apr_pool_t *p, const char *filename,
     fname = ap_server_root_relative(p, filename);
     if (!fname) {
         ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT, APR_EBADPATH,
-                     NULL, "Invalid PID file path %s, ignoring.", filename);
+                     NULL, APLOGNO(00101) "Invalid PID file path %s, ignoring.", filename);
         return APR_EGENERAL;
     }
 
@@ -1512,7 +1669,7 @@ AP_DECLARE(void) ap_log_assert(const char *szExp, const char *szFile,
     char time_str[APR_CTIME_LEN];
 
     apr_ctime(time_str, apr_time_now());
-    ap_log_error(APLOG_MARK, APLOG_CRIT, 0, NULL,
+    ap_log_error(APLOG_MARK, APLOG_CRIT, 0, NULL, APLOGNO(00102)
                  "[%s] file %s, line %d, assertion \"%s\" failed",
                  time_str, szFile, nLine, szExp);
 #if defined(WIN32)
@@ -1548,20 +1705,17 @@ static apr_status_t piped_log_spawn(piped_log *pl)
         ((status = apr_procattr_child_errfn_set(procattr, log_child_errfn))
          != APR_SUCCESS) ||
         ((status = apr_procattr_error_check_set(procattr, 1)) != APR_SUCCESS)) {
-        char buf[120];
         /* Something bad happened, give up and go away. */
-        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                     "piped_log_spawn: unable to setup child process '%s': %s",
-                     pl->program, apr_strerror(status, buf, sizeof(buf)));
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, status, NULL, APLOGNO(00103)
+                     "piped_log_spawn: unable to setup child process '%s'",
+                     pl->program);
     }
     else {
         char **args;
-        const char *pname;
 
         apr_tokenize_to_argv(pl->program, &args, pl->p);
-        pname = apr_pstrdup(pl->p, args[0]);
         procnew = apr_pcalloc(pl->p, sizeof(apr_proc_t));
-        status = apr_proc_create(procnew, pname, (const char * const *) args,
+        status = apr_proc_create(procnew, args[0], (const char * const *) args,
                                  NULL, procattr, pl->p);
 
         if (status == APR_SUCCESS) {
@@ -1576,11 +1730,10 @@ static apr_status_t piped_log_spawn(piped_log *pl)
             close_handle_in_child(pl->p, pl->read_fd);
         }
         else {
-            char buf[120];
             /* Something bad happened, give up and go away. */
-            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                         "unable to start piped log program '%s': %s",
-                         pl->program, apr_strerror(status, buf, sizeof(buf)));
+            ap_log_error(APLOG_MARK, APLOG_STARTUP, status, NULL, APLOGNO(00104)
+                         "unable to start piped log program '%s'",
+                         pl->program);
         }
     }
 
@@ -1591,7 +1744,7 @@ static apr_status_t piped_log_spawn(piped_log *pl)
 static void piped_log_maintenance(int reason, void *data, apr_wait_t status)
 {
     piped_log *pl = data;
-    apr_status_t stats;
+    apr_status_t rv;
     int mpm_state;
 
     switch (reason) {
@@ -1601,24 +1754,23 @@ static void piped_log_maintenance(int reason, void *data, apr_wait_t status)
                          * tells other logic not to try to kill it
                          */
         apr_proc_other_child_unregister(pl);
-        stats = ap_mpm_query(AP_MPMQ_MPM_STATE, &mpm_state);
-        if (stats != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
+        rv = ap_mpm_query(AP_MPMQ_MPM_STATE, &mpm_state);
+        if (rv != APR_SUCCESS) {
+            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, APLOGNO(00105)
                          "can't query MPM state; not restarting "
                          "piped log program '%s'",
                          pl->program);
         }
         else if (mpm_state != AP_MPMQ_STOPPING) {
-            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
+            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, APLOGNO(00106)
                          "piped log program '%s' failed unexpectedly",
                          pl->program);
-            if ((stats = piped_log_spawn(pl)) != APR_SUCCESS) {
+            if ((rv = piped_log_spawn(pl)) != APR_SUCCESS) {
                 /* what can we do?  This could be the error log we're having
                  * problems opening up... */
-                char buf[120];
-                ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                             "piped_log_maintenance: unable to respawn '%s': %s",
-                             pl->program, apr_strerror(stats, buf, sizeof(buf)));
+                ap_log_error(APLOG_MARK, APLOG_STARTUP, rv, NULL, APLOGNO(00107)
+                             "piped_log_maintenance: unable to respawn '%s'",
+                             pl->program);
             }
         }
         break;
@@ -1709,7 +1861,7 @@ AP_DECLARE(piped_log *) ap_open_piped_log_ex(apr_pool_t *p,
 
     rc = log_child(p, program, &dummy, cmdtype, 0);
     if (rc != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, APLOGNO(00108)
                      "Couldn't start piped log process '%s'.",
                      (program == NULL) ? "NULL" : program);
         return NULL;