You can use the PatternFileAppender to log to a separate file for each
logger. This appender is not built into the log4net assembly but is
included as an example in the log4net download.
examples\net\1.0\Appenders\SampleAppendersApp\cs\src\Appender\PatternFil
eAppender.cs
You will need to compile this into an assembly (one of your existing
assemblies or a new one).
Then you can configure the appender like this:
<appender
name="PatternFileAppender"
type="SampleAppendersApp.Appender.PatternFileAppender,
SampleAppendersApp">
<file
value="%logger.%date{yyyy-MM-dd}.log" />
<layout type="log4net.Layout.PatternLayout"
value="%date [%thread] %-5level %logger [%ndc] - %message%newline"
/>
</appender>
Update the type of the appender to point to the type in your assembly.
Cheers,
Nicko
> -----Original Message-----
> From: Giacomo Fiorentini [mailto:[EMAIL PROTECTED]
> Sent: 07 July 2006 17:09
> To: Log4NET User
> Subject: dispatching log to multiple file based on class
>
> I retry to submit my question:
>
> I need to create or configure existing log4net library so
> that I'll be able to have a log file for each class I decide to log.
>
> So briefly: one log-file for each class. Is it possible
> with log4net ?
> If yes how?
>
> For example suppose I have 2 classes:
>
> class C1 {
> protected static readonly ILog log =
> LogManager.GetLogger(typeof(C1 ));
> ...
> log.Debug(".... this write to C2.yyyymmdd.log ...."); }
>
> class C2 {
> protected static readonly ILog log =
> LogManager.GetLogger(typeof(C2 ));
> ...
> log.Debug("... this must write to C2.yyyymmdd.log file ..."); }
>
> Is it possibile with the current release in some way?
> If not, where can I start for building this type of logging
> behaviour ?
>
> More, is it possible to obtain the following log file name pattern?
> <full-namespace-class-name>.<yyyymmdd>.log
>
> 10x for any help.
>
> Regards.
>
>
>
> Giacomo Fiorentini
>
>