If you mean that you have 2 separate processes that are both logging the
same data to the same file, then you would expect the same messages to
be logged, both processes are doing the work, you would expect to see
the messages from both.

You might want to configure the layout to include the process id of the
process that is logging so that you can differentiate between your 2
processes.

Setup the process id in the GlobalContext when you initialise logging:

log4net.GlobalContext.Properties["processId"] =
System.Diagnostics.Process.GetCurrentProcess().Id;

Then add "%property{processId}" to your layout pattern.

If this isn't your scenario could you explain a little more your
architecture and the relationship between the appenders and the 2
processes calling the initialisation code.

> Also standard questions: log4net version, .net runtime 
> version, application type (ASP.NET/EXE)

Answering these might also be helpful.

Cheers,

Nicko

> -----Original Message-----
> From: Bonio Lopez [mailto:[EMAIL PROTECTED] 
> Sent: 14 July 2006 08:13
> To: 'Log4NET User'
> Subject: RE: Why each message printed 2 times?
> 
> Hi Niko,
> I understand now what is going on. The initialization code is 
> called from 2 processes and appender writes in the same file. 
> Is it possible somehow to attach to the same appender from 
> other process? Is there some "shared"
> log4net appender object, which can be acquired from other 
> process, when one process already initialized it?
> i.e.
> If XXX.already_initialized then attach else initialize.
> 
> Thank you very much
> 
> -----Original Message-----
> From: Nicko Cadell [mailto:[EMAIL PROTECTED]
> Sent: Mittwoch, 12. Juli 2006 10:34
> To: Log4NET User
> Subject: RE: Why each message printed 2 times?
> 
> This is usually caused by having 2 appenders writing to the 
> same output.
> These could be both attached to the same logger or to 
> different loggers (i.e. a logger and the root logger).
> 
> Can you post your complete configuration code (looks like you 
> are doing it in code rather than via an xml file). Or a 
> simplified version of your code that demonstrates this (just 
> the config code and a single log call would do). Are you 
> calling your config code only once or multiple times?
> 
> Have you enabled log4net's internal debugging?
> http://logging.apache.org/log4net/release/faq.html#internalDebug
> 
> Also standard questions: log4net version, .net runtime 
> version, application type (ASP.NET/EXE)
> 
> Cheers,
> Nicko
> 
> > -----Original Message-----
> > From: Bonio Lopez [mailto:[EMAIL PROTECTED]
> > Sent: 11 July 2006 17:51
> > To: 'Log4NET User'
> > Subject: Why each message printed 2 times?
> > 
> > Dear all,
> > With minimal lock each message is printed into a log file 2 times. 
> > i.e.
> > [11 Jul 2006 18:43:10,663] DEBUG Log1  - pi is nothing
> > [11 Jul 2006 18:43:10,663] DEBUG Log1  - pi is nothing With 
> exclusive 
> > lock works as expected.
> > Any ideas why?
> > 
> > 
> > 
> > m_LockingModel = new FileAppender.MinimalLock(); 
> m_FileAppender = new 
> > FileAppender(); m_FileAppender.Layout = new 
> > log4net.Layout.PatternLayout("[%date{dd MMM yyyy 
> HH:mm:ss,fff}] %level 
> > %logger  - %message%newline"); m_FileAppender.File = path_to_log + 
> > @"\" + m_logger_file_name; m_FileAppender.LockingModel = 
> > m_LockingModel; m_FileAppender.ImmediateFlush = true; 
> > m_FileAppender.AppendToFile = true;
> > 
> > 
> 
> 

Reply via email to