If you use the most recent code in CVS head, you can set a repository wide attributes such has the server hostname once and for all when you configure log4j (using JoranConfigrator). For values depending on the request, such as request server name, and remote address, these should be set using the MDC. In any case, the values you set on the repository wide level and/or the MDC level are merged together when the event is finally output. This was discussed a while ago.


Unfortunately I am unable to find a trace of this discussion in the mailing list archives either because it's there but I can't find it or maybe because it was held privately between Scott and myself. In conclusion, we should hold technical discussions on the log4j-dev list unless there is a good reason to hold them privately.



At 08:59 PM 6/24/2004, Sullivan, Sean C - MWT wrote:

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]

-- Ceki Gülcü

For log4j documentation consider "The complete log4j manual"
ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp




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



Reply via email to