【发布时间】:2019-09-21 22:36:40
【问题描述】:
如何添加目标以将日志发送到我的 Elasticsearch 服务器?理想情况下,我希望在我的 WCF 应用程序中有两个 errorLog,其中一个将数据发送到 SQL,另一个发送到 Elasticsearch。在我们关闭 SQL 端点之前,这是一个临时解决方案。
这是我目前拥有的:
web.config
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ErrorLog"/>
<errorLog type="My.Namespace.ElasticsearchErrorLog, My.Namespace" indexName="Elmah" />
<security allowRemoteAccess="false"/>
</elmah>
ElasticsearchErrorLog.cs
public class ElasticsearchErrorLog : Elmah.ErrorLog
{
public ElasticsearchErrorLog(IDictionary config)
{
}
public override ErrorLogEntry GetError(string id)
{
throw new NotImplementedException();
}
public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList)
{
throw new NotImplementedException();
}
public override string Log(Error error)
{
Logger.ElmahInstance.Error(error.Exception, "Something went wrong {Message} ...", error.Message);
return Guid.NewGuid().ToString();
}
}
有什么想法吗?
【问题讨论】:
标签: .net wcf elasticsearch elmah