Sorry for spamming your mailbox. I should have responded privately. My intention was to provide some working solution to Ravi's requirements after Nicko said it was not directly possible under log4net. NLog is a simple alternative to log4net providing very similar logging API and much easier to configure. That's why I wrote.. Sorry again.

FYI:

In NLog I measured the CPU overhead of recalculating the filename on each logging event, and it turns out that the performance hit is close to zero when compared to actually opening/writing to files. Of course you have some garbage but .NET is pretty good at GC.

I believe that the optimal solution is to have something similar to the threadpool concept but for files. The appender would keep a number of files open for quick writing, flush them on a regular basis and whenever a new file is requested that's not open, the last recently used file would be closed.

Jarek

----- Original Message ----- From: "Hollywood" <[EMAIL PROTECTED]>
To: "'Log4NET User'" <[email protected]>
Sent: Thursday, May 12, 2005 7:34 PM
Subject: RE: Multiple Log files



This is the Log4NET mailing list, why is NLog being mentioned here?  If
I'm interested in NLog and how to configure it, I'd subscribe to the
appropriate listing!

-----Original Message-----
From: Jaroslaw Kowalski [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 12, 2005 12:30 PM
To: Log4NET User
Subject: Re: Multiple Log files

NLog (http://nlog.sourceforge.net) can do it quite easily and it's 10
lines
of config code.

I'm attaching a fully working configuration for NLog that does advanced
log
routing
(taken unmodified from an actual server configuration).

In this example, each log goes into 3 file groups:

1. Per-user log, separated by year,month,day and user login:

logs/userlog/yyyy/MM/dd/yyyy-MM-dd.LOGIN.log

2. Per-request log - each HTTP request goes into its own file (0.log,
1.log,
2.log, ...) year,month,day:

logs/requestlog/yyyy/MM/dd/yyyy-MM-dd.COUNTER.log

3. warnings and errors for each day go to:

logs/yyyy-MM-dd.warnerror.log

To use it, just put NLog.dll in your web "bin" directory and web.nlog
next
to web.config. That's all. No other configuration is necessary.

As you can see, using layouts to specify file names can be pretty
powerful
technique. I found that I don't need any form of rolling appenders,
because
layouts give me much more. Specifying date/time as part of the filename
layout can make your logging really productive.

Jarek

----- Original Message ----- From: "Nicko Cadell" <[EMAIL PROTECTED]>
To: "Log4NET User" <[email protected]>
Sent: Wednesday, May 11, 2005 10:13 PM
Subject: RE: Multiple Log files



Having an log file for the server should be simple enough. It should
be
a FileAppender or RollingFileAppender configured as per

http://logging.apache.org/log4net/release/config-examples.html#fileappen
der
If you want to log everything or just certain code namespaces to this
file then that should be reflected in the <logger> config.

When you say you want a separate file per client, do you know in
advance
all the clients? Or are there an unlimited number of potential
clients?
Log4net does not currently have any support for a multiplexing
appender,
i.e. an appender that selectively routes to a potentially large set of
subappenders, and also has the ability to create these appenders. Do
you
want the client's log file to be held open once the client logs in, or
should the files be opened and closed per message?

It should be possible to extend the FileAppender to use a
PatternLayout
against the current LoggingEvent to generate the output filename on a
per event basis, the file could be cached open until the filename
changes, in that scenario you could set the client ID on the
ThreadContext.Properties and use that to switch the output filenames.

If the appender ends up rapidly switching between different log files
then the processor overhead may be high, but that depends on your
situation.

Depending on your requirements it may be easiest to write a new
appender
from scratch to support your one file per client scenario.

Cheers,

Nicko

-----Original Message-----
From: Shrivastava, Ravi [mailto:[EMAIL PROTECTED]
Sent: 11 May 2005 15:18
To: Log4NET User
Subject: Multiple Log files

I am trying to use Log4Net in a server enviroment. I would
like to have the following features:

1. One log file for the server
2. Individual log files for every client that logs in.

As the clients will be running in the same process/memory
space (of the server) - how do I configure Log4Net to do 1 &
2? Any help will be greatly appreciated.

-- RS.










Reply via email to