log4net.Appender.AdoNetAppender appender를 사용합니다.
내 log4net 테이블은 다음 필드입니다.[Date],[Thread],[Level],[Logger],[Message],[Exception]
log4net 테이블 (예 : SalesId)에 다른 필드를 추가해야하지만 오류 또는 정보 메시지를 기록 할 때 "SalesId"를 기록하기 위해 XML과 코드에서 어떻게 지정해야합니까?
예 : log.Info("SomeMessage", SalesId)
다음은 log4net xml입니다.
<appender name="SalesDBAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value ="System.Data.SqlClient.SqlConnection" />
<connectionString value="Data Source=..." />
<commandText value="INSERT INTO Log4Net ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" />
<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>
<parameter>
<parameterName value="@thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
<parameter>
<parameterName value="@log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="@logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="@message" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
<parameter>
<parameterName value="@exception" />
<dbType value="String" />
<size value="2000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>
</appender>