I was wondering what is the best practice for using log4net in Microsoft Orleans? Where should it be initialized?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With