You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Leo Mathew <le...@sonata-software.com> on 2010/01/20 13:19:46 UTC

Create new log files based on a variable value

Hi All,

 

I am using Log4Net.

 

Right now a log file is created based on the current date. So for each
day we have a log file containing all the debug statements.

 

We want to create a new log file based on a variable value in C#. For
each activity we have a requestId. So for each activity we need to
create a log file with the requestId.

 

Is it possible?

 

Regards,

Leo


Re: Create new log files based on a variable value

Posted by Shekar <sh...@gmail.com>.
You can try like this:

1. Set the file name dynamically using GlobalContext [you can ThreadContext
as well] property which the user who logged in.

2. Load the config file using XmlConfigurator.Configure(ConfigFile).

3. Now use GetLogger(type())

Please let me know if it works fine.

On Wed, Jan 20, 2010 at 5:49 PM, Leo Mathew <le...@sonata-software.com>wrote:

>  Hi All,
>
>
>
> I am using Log4Net.
>
>
>
> Right now a log file is created based on the current date. So for each day
> we have a log file containing all the debug statements.
>
>
>
> We want to create a new log file based on a variable value in C#. For each
> activity we have a requestId. So for each activity we need to create a log
> file with the requestId.
>
>
>
> Is it possible?
>
>
>
> Regards,
>
> Leo
>