Index: src/client.c
===================================================================
*** src/client.c	(revision 2825)
--- src/client.c	(working copy)
***************
*** 852,858 ****
          closesocket(fd[0]);
          dup2(fd[1], 0);
          dup2(fd[1], 1);
!         if(!global_options.option.foreground)
              dup2(fd[1], 2);
          closesocket(fd[1]);
          safecopy(env[0], "REMOTE_HOST=");
--- 852,858 ----
          closesocket(fd[0]);
          dup2(fd[1], 0);
          dup2(fd[1], 1);
!         if(!global_options.option.log_to_stderr)
              dup2(fd[1], 2);
          closesocket(fd[1]);
          safecopy(env[0], "REMOTE_HOST=");
Index: src/libwrap.c
===================================================================
*** src/libwrap.c	(revision 2825)
--- src/libwrap.c	(working copy)
***************
*** 82,88 ****
              drop_privileges(); /* libwrap processes are not chrooted */
              close(0); /* stdin */
              close(1); /* stdout */
!             if(!global_options.option.foreground) /* for logging in read_fd */
                  close(2); /* stderr */
              close(ipc_socket[2*i]); /* close server-side socket */
              for(j=0; j<i; ++j) /* previously created client-side sockets */
--- 82,88 ----
              drop_privileges(); /* libwrap processes are not chrooted */
              close(0); /* stdin */
              close(1); /* stdout */
!             if(!global_options.option.log_to_stderr) /* for logging in read_fd */
                  close(2); /* stderr */
              close(ipc_socket[2*i]); /* close server-side socket */
              for(j=0; j<i; ++j) /* previously created client-side sockets */
Index: src/log.c
===================================================================
*** src/log.c	(revision 2825)
--- src/log.c	(working copy)
***************
*** 158,164 ****
  #else /* Unix */
      if(mode==LOG_MODE_ERROR || /* always log LOG_MODE_ERROR to stderr */
              (level<=global_options.debug_level &&
!             global_options.option.foreground))
          fprintf(stderr, "%s\n", line); /* send log to stderr */
  #endif
  }
--- 158,164 ----
  #else /* Unix */
      if(mode==LOG_MODE_ERROR || /* always log LOG_MODE_ERROR to stderr */
              (level<=global_options.debug_level &&
!             global_options.option.log_to_stderr))
          fprintf(stderr, "%s\n", line); /* send log to stderr */
  #endif
  }
Index: src/options.c
===================================================================
*** src/options.c	(revision 2825)
--- src/options.c	(working copy)
***************
*** 253,261 ****
      case CMD_EXEC:
          if(strcasecmp(opt, "foreground"))
              break;
!         if(!strcasecmp(arg, "yes"))
              new_global_options.option.foreground=1;
!         else if(!strcasecmp(arg, "no"))
              new_global_options.option.foreground=0;
          else
              return "Argument should be either 'yes' or 'no'";
--- 253,262 ----
      case CMD_EXEC:
          if(strcasecmp(opt, "foreground"))
              break;
!         if(!strcasecmp(arg, "yes")) {
              new_global_options.option.foreground=1;
!             new_global_options.option.log_to_stderr=1;
!         } else if(!strcasecmp(arg, "no"))
              new_global_options.option.foreground=0;
          else
              return "Argument should be either 'yes' or 'no'";
***************
*** 465,470 ****
--- 466,496 ----
          break;
      }
  
+     /* stderr */
+ #ifndef USE_WIN32
+     switch(cmd) {
+     case CMD_INIT:
+         new_global_options.option.log_to_stderr=0;
+         break;
+     case CMD_EXEC:
+         if(strcasecmp(opt, "stderr"))
+             break;
+         if(!strcasecmp(arg, "yes"))
+             new_global_options.option.log_to_stderr=1;
+         else if(!strcasecmp(arg, "no"))
+             new_global_options.option.log_to_stderr=0;
+         else
+             return "Argument should be either 'yes' or 'no'";
+         return NULL; /* OK */
+     case CMD_DEFAULT:
+         break;
+     case CMD_HELP:
+         s_log(LOG_NOTICE, "%-15s = yes|no log to stderr",
+             "stderr");
+         break;
+     }
+ #endif
+ 
      /* syslog */
  #ifndef USE_WIN32
      switch(cmd) {
Index: src/prototypes.h
===================================================================
*** src/prototypes.h	(revision 2825)
--- src/prototypes.h	(working copy)
***************
*** 100,105 ****
--- 100,106 ----
          unsigned int taskbar:1;                   /* enable the taskbar icon */
  #else /* !USE_WIN32 */
          unsigned int foreground:1;
+         unsigned int log_to_stderr:1;
          unsigned int syslog:1;
  #endif
  #ifdef USE_FIPS
