我正在嘗試在我的服務結構web api項目上執行一些日誌記錄,並且它始終處於禁用狀態。我從來沒有見過這種行爲以前的任何其他SF項目類型。ServiceEventSource在Service Fabric Web API項目中禁用
[NonEvent]
public void ServiceMessage(ServiceContext serviceContext, string message, params object[] args)
{
if (IsEnabled())
{
string finalMessage = string.Format(message, args);
ServiceMessage(
serviceContext.ServiceName.ToString(),
serviceContext.ServiceTypeName,
GetReplicaOrInstanceId(serviceContext),
serviceContext.PartitionId,
serviceContext.CodePackageActivationContext.ApplicationName,
serviceContext.CodePackageActivationContext.ApplicationTypeName,
serviceContext.NodeContext.NodeName,
finalMessage);
}
}
IsEnabled總是返回false。您需要爲Web api項目進行特殊設置嗎?這也是.net核心。不知道這是否會影響它。
這並不是說我知道。你有沒有對EventSource類進行任何修改? –
除了EventSource屬性名稱字符串以外,完全沒有任何變化。但是我改變了我所有的服務結構項目。這個.net core web api SF項目是我見過這種行爲的唯一時間。我覺得我可能會在我的創業中失去一些東西,或者當我的weblistener正在被創建或者某些事情發生時。 –
你給這個名字叫什麼名字?看看我自己的一個web api無狀態服務,沒有任何設置要求,因此這個問題。也許這是一個無效的東西。 –