logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rafael Thome Guimaraes <p-rguimar...@bvmf.com.br>
Subject RE: Thread Safety in Log
Date Thu, 05 Sep 2013 22:51:44 GMT
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



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?

Rafael Thomé Guimarães
' +55 11 2565-7006
* p-rguimaraes@bvmf.com.br<mailto:p-bpedroso@bvmf.com.br>


[cid:image003.gif@01CBD760.1C45F490]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.


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


Bill Sorensen
Patterns, Platforms and Practices
Integrated DNA Technologies

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?

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.

View raw message