简体   繁体   English

Log4Net和奥尔良

[英]Log4Net and Orleans

I was wondering what is the best practice for using log4net in Microsoft Orleans? 我想知道在微软奥尔良使用log4net的最佳做法是什么? Where should it be initialized? 它应该在哪里初始化?

I think the best place to initialize per silo static variables is in Silo Bootstrap . 我认为初始化每个筒仓静态变量的最佳位置是Silo Bootstrap

Do note that Orleans has a logger configured and you can get it in grains by calling this.GetLogger() . 请注意,奥尔良配置了记录器,您可以通过调用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>可以定义一个继承自ILogConsumer的记录器,并通过调用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: <edit 2015-07-16>:这再次出现在Orleans Gitter频道 ,其核心团队成员提供以下建议

we publish to .NET Trace and you can ad new listeners to it. 我们发布到.NET Trace,你可以为它添加新的监听器。 that is actual the best way to do it, even without touching Orleans.Runtime.TraceLogger.LogConsumers. 这实际上是最好的方法,即使没有触及Orleans.Runtime.TraceLogger.LogConsumers。 just work with .NET TRace, with usual tools and config. 只需使用.NET TRace,使用常用工具和配置。 unrelated to Orleans. 与奥尔良无关。 we just publish into Trace. 我们只是发布到Trace。

An added point of note here to another Stackoverflow post Logging best practices , in which Sly Gryphon goes through trace infrastructure rather exhaustively. 这里还有一个值得注意的另一个Stackoverflow帖子记录最佳实践 ,其中Sly Gryphon通过跟踪基础设施进行了相当详尽的讨论。

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. Log4net使用相同的结构来创建ILog类。 There is no reason to use, or do this in an other way than the standard recommended way. 没有理由使用或以标准推荐方式以外的其他方式执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM