---
# System prepended metadata

title: C# `log4net` で `BufferingForwardingAppender` を使用する 2021-11-30
tags: [C#, BufferingForwardingAppender, log4net]

---

---
lang: ja-jp
breaks: true
---
# C# `log4net` で `BufferingForwardingAppender` を使用する 2021-11-30

> log4net BufferingForwardingAppender performance issue
> https://stackoverflow.com/questions/11319319/log4net-bufferingforwardingappender-performance-issue

> FixFlags
> http://logging.apache.org/log4net/log4net-1.2.12/release/sdk/log4net.Core.FixFlags.html

| Member Name | Description | Value | 
| -------- | -------- | -------- |
| Mdc | Obsolete.ï¿½ Replaced by composite Properties<br>Fix the MDC| 1
| Ndc | Fix the NDC| 2
| Message | Fix the rendered message| 4
| ThreadName | Fix the thread name| 8
| LocationInfo | Fix the callers location information| 16
| UserName | Fix the callers windows user name| 32
| Domain | Fix the domain friendly name| 64
| Identity | Fix the callers principal name| 128
| Exception | Fix the exception text| 256
| Properties | Fix the event properties. Active properties must implement IFixingRequired in order to be eligible for fixing.| 512
| None | No fields fixed| 0
| All | All fields fixed| 268435455
| Partial | Partial fields fixed| 844

```xml=
<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>
  <appSettings>
    <add key="log4net.Internal.Debug" value="false"/>
  </appSettings>
  <log4net>
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
      <param name="File"               value="${TEMP}\XXXXXXXX"/>
      <param name="AppendToFile"       value="true"/>
      <param name="RollingStyle"       value="Composite"/>
      <param name="StaticLogFileName"  value="false"/>
      <param name="DatePattern"        value="&quot;_&quot;yyyyMMdd&quot;.log&quot;"/>
      <param name="MaxSizeRollBackups" value="100"/>
      <param name="MaximumFileSize"    value="50MB"/>
      <layout type="log4net.Layout.PatternLayout">
        <header type="log4net.Util.PatternString" value="[ task time = &quot;%date{HH:mm:ss,fff}&quot;]%newline"/>
        <footer type="log4net.Util.PatternString" value="[/task time = &quot;%date{HH:mm:ss,fff}&quot;]%newline"/>
        <param name="ConversionPattern" value="%d [%-2t] %-5p %m%n"/>
      </layout>
      <Encoding value="UTF-8"/>
    </appender>

    <appender name="BufferingForwardingAppender" type="log4net.Appender.BufferingForwardingAppender">
      <bufferSize value="512000" />
      <appender-ref ref="RollingLogFileAppender" />
      <!--
      <Fix value="All"/>
      <Fix value="NONE"/>
      <Fix value="Partial"/>
      <Fix value="463"/>
      -->
      <Fix value="463"/>
    </appender>

    <root>
      <!-- ログのレベルを指定 -->
      <!-- すべてのログレベルを出力 -->
      <!--
      <level value="ALL" />
      <level value="DEBUG" />
      <level value="INFO" />
      <level value="WARN" />
      <level value="ERROR" />
      <level value="FATAL" />
      -->
      <level value="ALL"/>
      <!-- どのログ出力先を使用するか -->
      <!--
      <appender-ref ref="RollingLogFileAppender"/>
      <appender-ref ref="BufferingForwardingAppender" />
      -->
      <appender-ref ref="BufferingForwardingAppender"/>
    </root>

  </log4net>
</configuration>
```

###### tags: `log4net` `BufferingForwardingAppender` `C#`
