2016-06-19 1 views
0

私は、このアペンダを持っているアペンダのlog4netのシスログ:新しいラインのいくつかの問題

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ところでです:アペンダはスタックトレースなどの新しいログエントリが

<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> 

を書きます良い。

  1. スタックトレースが新しいログエントリとして何度も書き込まれるのを防ぐにはどうすればよいですか?
  2. RollingFileAppenderRemoteSyslogAppender私はconversionPatternに見られるようにスタックトレースを書きますが、アペンダは書き込みます。

おかげ

答えて

1

あなたのメッセージは、改行が含まれているが、これらはあなたがあなたのメッセージ(コンバータ)に\ rをまたは\ nを追加しないことで、これを防ぐwhould remotesysappender code (line 396):

373     while (i < message.Length) 
374     { 
375      // Clear StringBuilder 
376      builder.Length = 0; 
377 
378      // Write priority 
379      builder.Append('<'); 
380      builder.Append(priority); 
381      builder.Append('>'); 
382 
383      // Write identity 
384      builder.Append(identity); 
385      builder.Append(": "); 
386 
387      for (; i < message.Length; i++) 
388      { 
389       c = message[i]; 
390 
391       // Accept only visible ASCII characters and space. See RFC 3164 section 4.1.3 
392       if (((int)c >= 32) && ((int)c <= 126)) 
393       { 
394        builder.Append(c); 
395       } 
396       // If character is newline, break and send the current line 
397       else if ((c == '\r') || (c == '\n')) 
398       { 
399        // Check the next character to handle \r\n or \n\r 
400        if ((message.Length > i + 1) && ((message[i + 1] == '\r') || (message[i + 1] == '\n'))) 
401        { 
402         i++; 
403        } 
404        i++; 
405        break; 
406       } 
407      } 
408 
409      // Grab as a byte array 
410      buffer = this.Encoding.GetBytes(builder.ToString()); 
411 
412      this.Client.Send(buffer, buffer.Length, this.RemoteEndPoint); 
413     } 

に別の行として送信されています。

関連する問題