logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominik Psenner" <dpsen...@gmail.com>
Subject AW: Thread Safety in Log
Date Fri, 06 Sep 2013 06:32:44 GMT
At this point I usually quote Hector Correa:

 

 <http://hectorcorrea.com/blog/log4net-thread-safe-but-not-process-safe>
http://hectorcorrea.com/blog/log4net-thread-safe-but-not-process-safe

 

You can verify that log4net is indeed thread safe with a 3 liner console
application. However,  most people confuse thread safety with process
safety. log4net is – like many other programs - not process safe and that
has been written down in the FAQ several years ago:

 

 <http://logging.apache.org/log4net/release/faq.html#single-file>
http://logging.apache.org/log4net/release/faq.html#single-file

 

If log4net does not what you want it to do, then you’re probably using it in
a way it was not intended to be used.

 

Von: Rafael Thome Guimaraes [mailto:p-rguimaraes@bvmf.com.br] 
Gesendet: Freitag, 6. September 2013 00:52
An: Bill Sorensen; Log4NET User
Betreff: RE: Thread Safety in Log

 

Hi Bill!

 

Thanks for your answer!

 

My case is exactly the one of the l4ndash link you passed. I am using
“RollingFileAppender” through the ILog interface.

 

“

[…]

 

//Class field

private static ILog log =
LogManager.GetLogger(typeof(RSFNMessageBatchService));

 

[…]

 

//In the class constructor

log4net.GlobalContext.Properties["LogName"] =
AppSettings.GetValue("logFileName");

log4net.Config.XmlConfigurator.ConfigureAndWatch(new
System.IO.FileInfo(AppSettings.GetValue("log4NetConfigFile")));

log.Logger.Repository.Configured = true;

 

[…]

 

//Log call

log.Debug(mensagemLog);

 

[…]

 

”

 

In another file I just got, The trimmed message and the trimming message
came from the same thread! That eliminates the Thread Safety hypothesis.

 

Any ideas?

 

Thanks,

Rafael Thomé Guimarães

Analista-Programador

DO-CBCN / DI-CRAD - MIDDLEWARE

' +55 11 2565-7006

* p-rguimaraes@bvmf.com.br <mailto:p-bpedroso@bvmf.com.br> 



 

www.bmfbovespa.com.br <http://www.bmfbovespa.com.br/> 

 

 

Evite imprimir. Colabore com o Meio Ambiente!

 

 

 

From: Bill Sorensen [mailto:bsorensen@idtdna.com] 
Sent: quinta-feira, 5 de setembro de 2013 19:16
To: Rafael Thome Guimaraes; Log4NET User
Subject: RE: Thread Safety in Log

 

One of our developers (Eric Borman) researched this recently, so I’ll quote
him:

 

The short answer is that log4net is thread safe, the appenders are not.
log4net takes this into account and ensures proper serialization of logging
events. So as long as you use the logging API and don’t access the appender
directly you are safe.

 

http://stackoverflow.com/questions/1519211/multithread-safe-logging

http://www.l4ndash.com/Log4NetMailArchive%2Ftabid%2F70%2Fforumid%2F1%2Fposti
d%2F17279%2Fview%2Ftopic%2FDefault.aspx

 

However,

That does not make them process safe. So using a web garden will cause
collisions. 

 

http://hectorcorrea.com/blog/log4net-thread-safe-but-not-process-safe

 

Thanks,

_________________________________

Bill Sorensen

Patterns, Platforms and Practices

Integrated DNA Technologies

www.idtdna.com <http://www.idtdna.com> 

 

From: Rafael Thome Guimaraes [mailto:p-rguimaraes@bvmf.com.br] 
Sent: Thursday, September 05, 2013 3:49 PM
To: Log4NET User
Subject: Thread Safety in Log

 

Hi all!

 

Anyone knows if Log4Net is Thread Safe or I need to put locks in the calls?

 

Tks,

Rafael Thomé Guimarães

 

  _____  


Esta mensagem pode conter informação confidencial e/ou privilegiada. Se você
não for o destinatário ou a pessoa autorizada a receber esta mensagem, não
deverá utilizar, copiar, alterar, divulgar a informação nela contida ou
tomar qualquer ação baseada nessas informações. Se você recebeu esta
mensagem por engano, por favor avise imediatamente o remetente, respondendo
o e-mail e em seguida apague-o. Agradecemos sua cooperação.

This message may contain confidential and/or privileged information. If you
are not the addressee or authorized to receive this for the addressee, you
must not use, copy, disclose, change, take any action based on this message
or any information herein. If you have received this message in error,
please advise the sender immediately by reply e-mail and delete this
message. Thank you for your cooperation.


Mime
View raw message