Johann,

You will need to tag each log message with the client identifier. If
your server processes each client request on a separate thread then you
can just set a ThreadContext.Property e.g.:

ThreadContext.Property["client"] = clientId;

This property is then attached to the LoggingEvent and the appenders can
act on it. Typically this identifier would be written to the file or
database with each log event. The FileAppender does not support writing
to separate files selected on a per-event basis - which is roughly what
it sounds like you are after. However you should be able to do what you
want with the PatternFileAppender sample, see:

http://cvs.apache.org/viewcvs.cgi/logging-log4net/examples/net/1.0/Appen
ders/SampleAppendersApp/cs/src/Appender/PatternFileAppender.cs?rev=1.2&v
iew=markup

You can configure the appender like this:

<appender name="PatternFileAppender"
type="SampleAppendersApp.Appender.PatternFileAppender,
SampleAppendersApp">

  <file value="%property{client}\output.log" />

  <layout type="log4net.Layout.PatternLayout" value="%date [%thread]
%-5level %logger [%ndc] - %message%newline" />

</appender>

Note that the type will need to be updated to wherever you choose to
build the appender as it is not part of the log4net distribution.

Cheers,

Nicko

> -----Original Message-----
> From: Johann Rutnam [mailto:[EMAIL PROTECTED] 
> Sent: 14 June 2005 21:50
> To: [email protected]
> Subject: Multiple client log
> 
> Hi,
> 
> How do I use log4net to log message separately for each 
> client that accesses a service on the server? My server app 
> could identify each client but I need to log the messages 
> from the client separately (different folder/file for each client).
> 
> Johann
> 
> 
> ________________________________________________
> Get your own "800" number
> Voicemail, fax, email, and a lot more
> http://www.ureach.com/reg/tag
> 

Reply via email to