我正在尝试在Service Fabric服务(Web应用程序,Web API或无状态服务)中向ServiceEventSource类添加新方法,以便将警告和异常与信息类型消息分开记录。
当我向ServiceEventSource类添加新方法时,它不输出任何消息,this.IsEnabled()返回false。开箱即用,如果我删除新添加的方法,ServiceEventSource按预期输出消息,this.IsEnabled()返回true。
我正在关注Using EventSource generically样本。 例如,只需添加以下代码将导致ServiceEventSource停止记录:
private const int ErrorEventId = 7;
[Event(ErrorEventId, Level = EventLevel.Error, Message = "Error: {0} - {1}")]
public void Error(string error, string msg)
{
WriteEvent(ErrorEventId, error, msg);
}
我到处寻找,找不到任何对这种意外行为的引用。