You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Stanley Gambarin <st...@cs.bu.edu> on 1997/07/21 18:24:11 UTC

additional logging facility

	The patch below allows you to do something like 
Errorlog somehost:portnum, where all error messages would go 
to a designated host:port via TCP connection.  Yes, I am aware
that the same functionality is achievable via ErrorLog |prog,
where prog establishes a connection to host:port, however, (a)
this eliminates the need to check whether prog has died or what,
and (b) removes need for a user to write their own programs to do
the communication stuff.  Also, note that code above uses virt_host
function, which does the same stuff as I wanted to do, which brings
me to the point that these kind of functions should be abstracted,
say something like create_tcp_socket() and create_udp_socket(), which
i will take a look later on.  The above functions would be also useful
for modules (i know for a fact that mod_fastcgi does a lot of stuff 
with external sockets and this would be a good addition).
							Stanley.

P.S. code should also be expanded to add support for logging via
UDP and using unix domain sockets.  Just some random babble.



*** http_log.c	Mon Jul 21 02:04:50 1997
--- http_log.c.bak	Mon Jul 21 02:05:55 1997
***************
*** 94,123 ****
  
  void open_error_log(server_rec *s, pool *p)
  {
!     char *fname, *port;
!     int sock_fd;
!     struct sockaddr_in serv_addr;
! 
!     if ((port = strchr(s->error_fname, ':')) != NULL) {
!         /* dealing with host:port logging facility */
!         memset((char *)&serv_addr, 0, sizeof(serv_addr));
! 	serv_addr.sin_family = AF_INET;
! 	serv_addr.sin_addr.s_addr = get_virthost_addr(s->error_fname, 
! 						      NULL);
! 	serv_addr.sin_port = htons(atoi(port+1));
! 
! 	if ((sock_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
! 	    fprintf(stderr, "No socket\n");
! 	    exit (1);
! 	} else if (connect (sock_fd, (struct sockaddr *)&serv_addr, 
! 			    sizeof(serv_addr)) < 0) {
! 	    fprintf(stderr, "No connect\n");
! 	    exit (2);
! 	}
! 	s->error_log = fdopen(sock_fd, "w");
! 	return;
!     } 
! 
      fname = server_root_relative (p, s->error_fname);
  
      if (*s->error_fname == '|') {
--- 94,101 ----
  
  void open_error_log(server_rec *s, pool *p)
  {
!     char *fname;
!   
      fname = server_root_relative (p, s->error_fname);
  
      if (*s->error_fname == '|') {



Re: additional logging facility

Posted by Dean Gaudet <dg...@arctic.org>.
On Mon, 21 Jul 1997, Stanley Gambarin wrote:

> that the same functionality is achievable via ErrorLog |prog,
> where prog establishes a connection to host:port, however, (a)
> this eliminates the need to check whether prog has died or what,

But you have to test if the socket has died.  Which is just as bothersome
as the child code... so I should get off my butt and write the reliable
piped child code. 

Dean