6 messages in org.apache.logging.log4j-userRE: Database logging: server name
FromSent OnAttachments
James StaufferJun 24, 2004 11:54 am 
Sullivan, Sean C - MWTJun 24, 2004 11:59 am 
James StaufferJun 24, 2004 12:00 pm 
Sullivan, Sean C - MWTJun 24, 2004 12:09 pm 
James StaufferJun 24, 2004 12:23 pm 
Ceki GülcüJun 25, 2004 2:56 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:RE: Database logging: server nameActions...
From:Sullivan, Sean C - MWT (Sull@menlolog.com)
Date:Jun 24, 2004 11:59:13 am
List:org.apache.logging.log4j-user

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:jsta@spscommerce.com] 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?