Hi,

I'm writing an audit log utility for our product using log4net. There are custom fields need to be output. I used MDC to set those fields every time before calling ILog.Debut() (or Error(), Fatal()...). The following is the sample code

// Set output fields
log4net.MDC.Set("theUser", strUser);
log4net.MDC.Set("sessionid", strSession);
log4net.MDC.Set("machine", strClientMachine);

//Output data
log.Warn(message);

Because during the same session (thread) the above data is the same. I'm wondering if there is threadsafe storage in log4net so that the setting output fields block is only called once. The audit log utility is used enormously in our product. Therefore performance is very critical.

I'd appreciate it if any one can show me a better solution or point me to related documents. By the way, I'm using log4net 1.2 beta8. We can upgrade it if needed.

Thank you in advance.

Ping Xie

CACI
4831 Walden Lane
Lanham, MD 20706
[EMAIL PROTECTED]
(301) 306-8200 - Main
(301) 306-2829 - Direct

Reply via email to