--- auto/make.orig	2009-05-12 20:15:43.000000000 +0700
+++ auto/make	2009-07-08 16:32:06.000000000 +0700
@@ -15,6 +15,10 @@
 ngx_objs_dir=$NGX_OBJS$ngx_regex_dirsep
 ngx_use_pch=`echo $NGX_USE_PCH | sed -e "s/\//$ngx_regex_dirsep/g"`
 
+#SYSLOG
+if [[ "${USE_SYSLOG}" == "YES" ]]; then
+    CFLAGS="$CFLAGS -DUSE_SYSLOG"
+fi
 
 cat << END                                                     > $NGX_MAKEFILE
 
--- auto/options.orig	2009-05-18 23:50:32.000000000 +0700
+++ auto/options	2009-07-08 17:57:57.000000000 +0700
@@ -102,6 +102,8 @@
 PCRE=NONE
 PCRE_OPT=
 
+USE_SYSLOG=NO
+
 USE_OPENSSL=NO
 OPENSSL=NONE
 
@@ -245,6 +247,8 @@
         --with-pcre=*)                   PCRE="$value"              ;;
         --with-pcre-opt=*)               PCRE_OPT="$value"          ;;
 
+        --with-syslog)                   USE_SYSLOG=YES             ;;
+
         --with-openssl=*)                OPENSSL="$value"           ;;
         --with-openssl-opt=*)            OPENSSL_OPT="$value"       ;;
 
@@ -377,6 +381,8 @@
   --with-pcre=DIR                    set path to PCRE library sources
   --with-pcre-opt=OPTIONS            set additional options for PCRE building
 
+  --with-syslog                      use syslog instead of files to log messages
+
   --with-md5=DIR                     set path to md5 library sources
   --with-md5-opt=OPTIONS             set additional options for md5 building
   --with-md5-asm                     use md5 assembler sources
--- auto/summary.orig	2009-05-26 21:28:49.000000000 +0700
+++ auto/summary	2009-07-08 16:35:19.000000000 +0700
@@ -43,6 +43,11 @@
     esac
 fi
 
+case $USE_SYSLOG in
+    YES)   echo "  + using syslog" ;;
+    *)     echo "  + syslog is not used" ;;
+esac
+
 case $OPENSSL in
     YES)   echo "  + using system OpenSSL library" ;;
     NONE)  echo "  + OpenSSL library is not used" ;;
--- src/core/nginx.c.orig	2009-06-06 19:41:31.000000000 +0700
+++ src/core/nginx.c	2009-07-08 16:39:57.000000000 +0700
@@ -8,6 +8,9 @@
 #include <ngx_core.h>
 #include <nginx.h>
 
+#ifdef USE_SYSLOG
+#include <syslog.h>
+#endif
 
 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle);
 static ngx_int_t ngx_get_options(int argc, char *const *argv);
@@ -271,6 +274,11 @@
     ngx_ssl_init(log);
 #endif
 
+    /* SYSLOG SUPPORT */
+#ifdef USE_SYSLOG
+    openlog("nginx", LOG_ODELAY, LOG_DAEMON);
+#endif
+
     /*
      * init_cycle->log is required for signal handlers and
      * ngx_process_options()
@@ -382,6 +390,10 @@
         ngx_master_process_cycle(cycle);
     }
 
+#ifdef USE_SYSLOG
+    closelog();
+#endif
+
     return 0;
 }
 
--- src/core/ngx_conf_file.c.orig	2009-06-02 21:00:01.000000000 +0700
+++ src/core/ngx_conf_file.c	2009-07-08 19:25:57.000000000 +0700
@@ -907,6 +907,12 @@
     full.data = NULL;
 #endif
 
+#ifdef USE_SYSLOG
+    if (name->len) {
+      name->len = 0;
+    }
+#endif
+
     if (name->len) {
         full = *name;
 
--- src/core/ngx_log.c.orig	2009-04-30 20:53:42.000000000 +0700
+++ src/core/ngx_log.c	2009-07-08 19:26:02.000000000 +0700
@@ -7,6 +7,9 @@
 #include <ngx_config.h>
 #include <ngx_core.h>
 
+#ifdef USE_SYSLOG
+#include <syslog.h>
+#endif
 
 static char *ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
 
@@ -90,16 +93,22 @@
     u_char  *p, *last, *msg;
     u_char   errstr[NGX_MAX_ERROR_STR];
 
+#ifndef USE_SYSLOG
     if (log->file->fd == NGX_INVALID_FILE) {
         return;
     }
+#endif
 
     last = errstr + NGX_MAX_ERROR_STR;
 
+#ifdef USE_SYSLOG
+    p = errstr;
+#else
     ngx_memcpy(errstr, ngx_cached_err_log_time.data,
                ngx_cached_err_log_time.len);
 
     p = errstr + ngx_cached_err_log_time.len;
+#endif
 
     p = ngx_slprintf(p, last, " [%V] ", &err_levels[level]);
 
@@ -139,7 +148,21 @@
 
     ngx_linefeed(p);
 
+#ifdef USE_SYSLOG
+    /* allocate a string which can hold the error message */
+    char *syslogstr;
+
+    if ((syslogstr = calloc((p - errstr + 1), sizeof(char))) != NULL) {
+      strncpy(syslogstr, errstr, p - errstr);
+
+      /* write to syslog */
+      syslog(LOG_CRIT, "%s", syslogstr);
+
+      free(syslogstr);
+    }
+#else
     (void) ngx_write_fd(log->file->fd, errstr, p - errstr);
+#endif
 
     if (!ngx_use_stderr
         || level > NGX_LOG_WARN
@@ -267,7 +290,11 @@
     ngx_log.file = &ngx_log_file;
     ngx_log.log_level = NGX_LOG_NOTICE;
 
+#ifndef USE_SYSLOG
     name = (u_char *) NGX_ERROR_LOG_PATH;
+#else
+    name = "";
+#endif
 
     /*
      * we use ngx_strlen() here since BCC warns about
@@ -428,6 +455,10 @@
 
     value = cf->args->elts;
 
+#ifdef USE_SYSLOG
+    value[1].data = "stderr";
+#endif
+
     if (ngx_strcmp(value[1].data, "stderr") == 0) {
         name.len = 0;
         name.data = NULL;
--- src/http/modules/ngx_http_log_module.c.orig	2009-06-02 23:09:44.000000000 +0700
+++ src/http/modules/ngx_http_log_module.c	2009-07-08 19:56:29.000000000 +0700
@@ -8,6 +8,9 @@
 #include <ngx_core.h>
 #include <ngx_http.h>
 
+#ifdef USE_SYSLOG
+#include <syslog.h>
+#endif
 
 typedef struct ngx_http_log_op_s  ngx_http_log_op_t;
 
@@ -183,7 +186,7 @@
 
 
 static ngx_str_t  ngx_http_combined_fmt =
-    ngx_string("$remote_addr - $remote_user [$time_local] "
+    ngx_string("$remote_addr - $remote_user "
                "\"$request\" $status $body_bytes_sent "
                "\"$http_referer\" \"$http_user_agent\"");
 
@@ -310,6 +313,19 @@
 ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf,
     size_t len)
 {
+#ifdef USE_SYSLOG
+  /* allocate a string which can hold the error message */
+  char *syslogstr;
+
+  if ((syslogstr = calloc((len + 1), sizeof(char))) != NULL) {
+    strncpy(syslogstr, buf, len);
+
+    /* write to syslog */
+    syslog(LOG_NOTICE, "%s", syslogstr);
+
+    free(syslogstr);
+  }
+#else
     u_char     *name;
     time_t      now;
     ssize_t     n;
@@ -354,6 +370,7 @@
 
         log->error_log_time = now;
     }
+#endif
 }
 
 
@@ -800,6 +817,9 @@
         return NGX_CONF_ERROR;
     }
 
+#ifdef USE_SYSLOG
+    ngx_http_access_log.data = NULL;
+#endif
     log->file = ngx_conf_open_file(cf->cycle, &ngx_http_access_log);
     if (log->file == NULL) {
         return NGX_CONF_ERROR;
@@ -859,6 +879,9 @@
     n = ngx_http_script_variables_count(&value[1]);
 
     if (n == 0) {
+#ifdef USE_SYSLOG
+        value[1].data = NULL;
+#endif
         log->file = ngx_conf_open_file(cf->cycle, &value[1]);
         if (log->file == NULL) {
             return NGX_CONF_ERROR;
