Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log4Net and Orleans

I was wondering what is the best practice for using log4net in Microsoft Orleans? Where should it be initialized?

like image 715
Vojtech B Avatar asked Feb 24 '15 16:02

Vojtech B


2 Answers

I think the best place to initialize per silo static variables is in Silo Bootstrap.

Do note that Orleans has a logger configured and you can get it in grains by calling this.GetLogger().

<edit>One can define a logger inheriting from ILogConsumer and add it the collection of log sinks by calling Orleans.Runtime.TraceLogger.LogConsumers.Add().</edit>

<edit 2015-07-16>: This came out in Orleans Gitter channel again, where the following advice was offered from the core team member:

we publish to .NET Trace and you can ad new listeners to it. that is actual the best way to do it, even without touching Orleans.Runtime.TraceLogger.LogConsumers. just work with .NET TRace, with usual tools and config. unrelated to Orleans. we just publish into Trace.

An added point of note here to another Stackoverflow post Logging best practices, in which Sly Gryphon goes through trace infrastructure rather exhaustively.

like image 160
Veksi Avatar answered Nov 15 '22 13:11

Veksi


In almost all Orleans sample there is use of static class for as factories for object creation. Log4net uses the same structure to create the ILog classes. There is no reason to use, or do this in an other way than the standard recommended way.

like image 45
Peter Avatar answered Nov 15 '22 13:11

Peter