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
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>
[cid:image001.gif@01C9D55A.E5179270]

www.bmfbovespa.com.br<http://www.bmfbovespa.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.

http://stackoverflow.com/questions/1519211/multithread-safe-logging
http://www.l4ndash.com/Log4NetMailArchive%2Ftabid%2F70%2Fforumid%2F1%2Fpostid%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