如何在Akka.NET中禁用集群心跳日志记录

时间:2016-08-09 18:07:00

标签: logging akka.net

尝试对Akka.NET中的群集设置进行故障排除时,群集心跳消息正在填充日志。

  

[DEBUG] [8/9/2016 6:04:32 PM] [线程   0011] [[阿卡:// mysystem /系统/群集/型芯/守护进程#1680718572]]   [初始化]收到Akka.Cluster.GossipStatus

有没有办法可以选择性地阻止此日志事件{?3}}?

2 个答案:

答案 0 :(得分:3)

我遇到了同样的问题。日志中有太多的八卦消息,我想阻止它。

这是一个解决方案。

https://github.com/akkadotnet/akka.net/blob/v1.1.2/src/core/Akka.Cluster/Configuration/Cluster.conf#L77

所以要避免使用像这样的GossipStatus消息来污染日志(类似于你的例子):

[DEBUG][2016-12-26 1:48:36 PM][Thread 0004][[akka://mysystem/system/cluster/core/daemon#1458732427]] [Initialized] Received Akka.Cluster.GossipStatus

您只需要关闭以下选项:

cluster {
    log-info = off
}

同时,如果你打开了远程选项:

remote {
    log-received-messages = on
}

然后您仍会记录一些cluster gossip条消息(如@Aaronontheweb所述),但这些消息不同。 比较例如:

[DEBUG][2016-12-26 1:41:03 PM][Thread 0008][[akka://mysystem/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2Fmysystem%40127.0.0.1%3A4053-1/endpointWriter#1021888826]] received local message [RemoteMessage: Akka.Cluster.ClusterHeartbeatSender+HeartbeatRsp to [akka://mysystem/system/cluster/core/daemon/heartbeatSender#647951916]<+akka://mysystem/system/cluster/core/daemon/heartbeatSender from [akka.tcp://mysystem@127.0.0.1:4053/system/cluster/heartbeatReceiver#497245242]]
[DEBUG][2016-12-26 1:41:04 PM][Thread 0010][[akka://mysystem/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2Fmysystem%40127.0.0.1%3A4053-1/endpointWriter#1021888826]] received local message [RemoteMessage: ActorSelectionMessage - Message: Akka.Cluster.GossipStatus - WildCartFanOut: False - Elements: system/cluster/core/daemon to [akka://mysystem/]<+akka://mysystem/ from [akka.tcp://mysystem@127.0.0.1:4053/system/cluster/core/daemon#1365688409]]
[DEBUG][2016-12-26 1:41:04 PM][Thread 0009][[akka://mysystem/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2Fmysystem%40127.0.0.1%3A4053-1/endpointWriter#1021888826]] received local message [RemoteMessage: ActorSelectionMessage - Message: Akka.Cluster.ClusterHeartbeatSender+Heartbeat - WildCartFanOut: False - Elements: system/cluster/heartbeatReceiver to [akka://mysystem/]<+akka://mysystem/ from [akka.tcp://mysystem@127.0.0.1:4053/system/cluster/core/daemon/heartbeatSender#2069081679]]

答案 1 :(得分:1)

默认情况下,应禁用详细的心跳记录https://github.com/akkadotnet/akka.net/blob/dev/src/core/Akka.Cluster/Configuration/Cluster.conf#L165

但是,如果您打开了Akka.Remote的日志接收消息,则会记录此类八卦消息:

https://github.com/akkadotnet/akka.net/blob/dev/src/core/Akka.Remote/Configuration/Remote.conf#L121

在您使用特定记录器实现(logback)之前链接到的JVM示例中,过滤掉生成日志消息的actor的类名,而不是Akka.NET本身内置的内容。您可以使用某些更高级别的日志记录框架(例如.NET中的Serilog或NLog)来执行相同的操作。