【发布时间】:2016-06-28 05:36:27
【问题描述】:
我有这个附加程序:
<appender name="Syslog" type="log4net.Appender.RemoteSyslogAppender">
<param name="RemoteAddress" value="**.***.***.**" />
<param name="RemotePort" value="514" />
<facility value="Local6" />
<identity value="Widgets" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%property{NDC}] [%-5level] [%logger] [%property{url}] [%message] [%thread] %newline" />
</layout>
</appender>
appender 将 stacktrace 写为 new 日志条目:
Jun 19 20:06:33 adminclou6PBAYR Widgets: [2016-06-19 20:06:21,156] [0JUK68M] [ERROR] [Widgets.Web.HandleWebErrorAttribute] [~/Customer/RegisterWithEmailForm] [The given key was not present in the dictionary.] [16]
Jun 19 20:06:33 adminclou6PBAYR Widgets: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
Jun 19 20:06:33 adminclou6PBAYR Widgets: at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
Jun 19 20:06:33 adminclou6PBAYR Widgets: at Widgets.Web.LabelExtensions.TranslatedLabelFor[TModel,TValue](HtmlHelper`1 html, Expression`1 expression, IDictionary`2 htmlAttributes)
Jun 19 20:06:33 adminclou6PBAYR Widgets: at ASP._Page_Views_Customer_RegisterWithEmailForm_cshtml.Execute() in c:\inetpub\wwwroot\HL\Widgets\Views\Customer\RegisterWithEmailForm.cshtml:line 4
Jun 19 20:06:33 adminclou6PBAYR Widgets: at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
Jun 19 20:06:33 adminclou6PBAYR Widgets: at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
Jun 19 20:06:33 adminclou6PBAYR Widgets: at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
RollingFileAppender BTW 很好。
- 如何防止堆栈跟踪一次又一次地被写入新的日志条目?
- 在
RollingFileAppender和RemoteSyslogAppender中,我没有要求编写堆栈跟踪,正如您在conversionPattern 中看到的那样,但附加程序仍会编写它。
谢谢
【问题讨论】: