Skip to content

Instantly share code, notes, and snippets.

@nowsathns
Last active September 22, 2019 15:31
Show Gist options
  • Save nowsathns/db1672a1b7f19fbaab7ba763908134a8 to your computer and use it in GitHub Desktop.
Save nowsathns/db1672a1b7f19fbaab7ba763908134a8 to your computer and use it in GitHub Desktop.
Log4Net Configuration for Ado.Net Appender & S3 Appender
<?xml version="1.0"?>
<log4net debug="true">
<root>
<level value="DEBUG" />
<appender-ref ref="AdoNetAppender"/>
<appender-ref ref="S3Appender"/>
</root>
<appender name="S3Appender" type="log4net.Appender.RollingFileS3Appender, log4net.Appender.AWS">
<param name="BucketName" value="logs-jcbapostas" />
<param name="LogDirectory" value="log-diagnostics" />
<!-- If you dont whant a prefix to the log object leave this blank -->
<param name="File" value="_logs\\LogSocket.log" />
<staticLogFileName value="true" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="1MB" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t][%property{SessionID}] %-5p %c %m%n" />
</layout>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
</appender>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection,
System.Data,
Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
<connectionStringName value="IVYDMS_Context" />
<commandText value="INSERT INTO AppLogs (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>
</log4net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment