Search code examples
c#log4netorleans

Log4Net and Orleans


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


Solution

  • 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.