Logging Errors to the Database

As of mojoPortal, we introduced a new logging appender for log4net that allows logging to the database instead of to the /Data/currentlog.config file. log4net is the underlying logging framework we use in mojoPortal for logging errors and other information about system events.

The mojoPortal log can also be viewed from the UI at Administration > System Log

In order to enable logging to the database you need to edit the log4net.config file in the root of your site, and you will need to remember to not overwrite your custom log4net.config file during upgrades.

To use database logging, uncomment this in log4net.config
    <appender-ref ref="mojoSystemLogAppender" />
optionally disable file system logging by commenting out
<appender-ref ref="RollingLogFileAppender" />
in log4net.config

Then add <add key="UseSystemLogInsteadOfFileLog" value="true" /> to user.config and touch Web.config to make it reload settings since it will not automatically detect changes in user.config.

Typically there is no reason to log to both the file system and the database, but it is possible if you don't comment out the RollngLogAppender in log4net.config

and if you want to be able to view both the file system log and the database log from the UI, you can add this to user.config

<add key="ShowFileLogInAdditionToSystemLog" value="true" />

Additional config settings and their default values:

<add key="SystemLogDeleteOldEventsOnApplicationStart" value="true" />
<add key="SystemLogApplicationStartDeleteOlderThanDays" value="10" />
<add key="SystemLogPageSize" value="10" />
<add key="SystemLogSortAscending" value="false" />


Created 2011-09-27 by Joe Audette
Updated 2012-03-27 by Joe Audette