Is there a way to avoid setting it get each request?  Or is that probably
irrelevant performance wise (we have somewhat long requests)?

-----Original Message-----
From: Sullivan, Sean C - MWT [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 24, 2004 2:00 PM
To: Log4J Users List
Subject: RE: Database logging: server name



In our environment, we store the server hostname in 
the MDC.

First, we put the server hostname in a static variable:

  static private final String strServerHostname = getServerHostname();

For each HTTP request, we execute this code:

  MDC.put(SERVER_HOSTNAME_KEY, strServerHostname);
  MDC.put(REQUEST_SERVER_NAME_KEY, req.getServerName());
  MDC.put(REQUEST_REMOTE_ADDRESS_KEY, req.getRemoteAddr());

-Sean

> -----Original Message-----
> From: James Stauffer [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, June 24, 2004 11:55 AM
> To: 'Log4J Users List'
> Subject: Database logging: server name
> 
> 
> Since we have 16 servers running one product we would like the logs to
> include the server name.  Is there a way to make that happen 
> automatically?
> I was using an MDC value but I found that it wasn't always 
> being set.  It
> appears that since the servlet engine created multiple 
> threads before my
> static code ran to set the MDC it was only set on one thread. 
>  I don't want
> to set it on every request because it never changes.  Ideas?
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to