<< Click to Display Table of Contents >> Navigation: Administration and Configuration > App Config Files > log4net.config |
The Apache log4net library is a tool to help the programmer output log statements to a variety of output targets. Log4net is a part of the excellent Apache log4j™ framework to the Microsoft® .NET runtime (see https://logging.apache.org/log4net/license.html).
EQuIS uses log4net for debug logging. While the RollingLogFileAppender is useful to troubleshooting database connectivity issues, it places a significant performance tax on the EQuIS Enterprise application. Additionally, altering the log configuration requires remote access to the application server to modify this file. Hence, the ability to manage logging through the ST_CONFIG table was introduced. EarthSoft recommends leaving the AdoNetAppender configured as is and using the ST_CONFIG setting to manage error logging.
EQuIS 7.20.3 added a security logger called ‘EarthSoft.Common.log4net.SecurityLogger’ to the log4net.config file. This logger logs security events, such as failed logins, administrator logins, and user impersonations. This feature is disabled by default but can be enabled by changing the level value for the logger to either “warn” or “info” on approximately line 108. Setting the level value to “warn” will capture user impersonations and failed logins, and setting the level value to “info” will capture successful admin logins, user impersonations, and failed logins.
Please note that the connectionString value {ConnectionString} will be replaced with the current connection string at run time. There is no need to provide a connection string unless the aim is to log to a different database.
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<!--
This section defines the "appenders" used to store log messages.
Other appenders are available (TraceContext, database, Event Log, SMTP, etc.).
For more information, see:
http://logging.apache.org/log4net/release/config-examples.html
-->
<!--
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="%env{temp}/equislogs/{baseUri}/{process}.log" />
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="10" />
<param name="MaximumFileSize" value="500KB" />
<param name="RollingStyle" value="Size" />
<param name="StaticLogFileName" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d %property{url} %property{ip} [%t] %-5p %c [%x] - %m%n" />
</layout>
</appender>
-->
<appender name="SecurityLoggerFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="%env{temp}/equislogs/{baseUri}/security.log" />
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="10" />
<param name="MaximumFileSize" value="500KB" />
<param name="RollingStyle" value="Size" />
<param name="StaticLogFileName" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d %property{url} %property{ip} [%t] %-5p %c [%x] - %m%n" />
</layout>
</appender>
<!--
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d %property{url} %property{ip} [%t] %-5p %c [%x] - %m%n"/>
</layout>
</appender>
-->
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionString value="{ConnectionString}" />
<commandText value="INSERT INTO st_log (log_date,log_thread,log_level,logger,message, log_trace) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" />
<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}" />
</parameter>
<parameter>
<parameterName value="@thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout" value="%thread" />
</parameter>
<parameter>
<parameterName value="@log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout" value="%level" />
</parameter>
<parameter>
<parameterName value="@logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout" value="%logger" />
</parameter>
<parameter>
<parameterName value="@message" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%message (%property{url} %property{ip} %property{culture})" />
</layout>
</parameter>
<parameter>
<parameterName value="@exception" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>
</appender>
<!-- logger(s) disabled by default -->
<logger name="EarthSoft.Common.Helpers.AssemblyHelper">
<level value="off" />
</logger>
<logger name="EarthSoft.API.Core.Helpers.DeviceToken">
<level value="off" />
</logger>
<logger name="EarthSoft.API.Core.Helpers.SessionToken">
<level value="off" />
</logger>
<!-- Security Logger
Administrator login success,
failed login attempts,
user impersonation by administrators,
EarthSoft Support access. -->
<logger name="EarthSoft.Common.log4net.SecurityLogger">
<level value="off"/>
<appender-ref ref="SecurityLoggerFileAppender"/>
</logger>
<!-- what level of logging do you want to use:
warn: only logs errors and warnings
all: logs errors, warnings, and information messages (uses more disk space)
-->
<root>
<level value="off" />
<!--<appender-ref ref="RollingLogFileAppender" />-->
<!--<appender-ref ref="ConsoleAppender"/>-->
<appender-ref ref="AdoNetAppender"/>
</root>
</log4net>
Copyright © 2023 EarthSoft, Inc • Modified: 09 Mar 2021