Login

How do I create a log in EPiServer?

Versions: n/a, FAQ number: 155, Old FAQ number: 6486

The logging function in EPiServer is very useful when troubleshooting different issues. To log everything, create an EPiServerLog.config file in the root of your website and add this:


<?xml version="1.0" encoding="utf-8" ?>
<log4net>
      <appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
        <file value="c:\\EPiServerLog\\1\\Monitor\\Error-log.txt" />
        <appendToFile value="true" />
        <rollingStyle value="Date" />
        <layout type="log4net.Layout.PatternLayout">
           <param name="ConversionPattern" value="%d\t%X{siteid}\t%m%n" />
        </layout>
      </appender>
      <root>
            <level value="ALL" />
            <appender-ref ref="FileAppender" />
      </root>
</log4net>


Note! You might have an EPiServerLog.config file there already, just change that to include the tags above, if not already there, and you should be good to go.

No logs ? Remember that ASPNET on Windows XP/2000 and IIS_WPG on Windows 2003 need Change access on this directory, log4net is quiet by nature so you will not get any notifications about this.

You can add more information to the log file by changing the pattern, see http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html for more information.

All EPiServer logging messages are documented in technote Logging in EPiServer CMS, a good starting point if you want to know what EPiServer logs for a particulal functionality and on what levels (DEBUG, WARN etc).

This will dump alot of interesting things to your logfile, actually so much information that it can be hard to keep up. Tail to the rescue. Download Tail for Win32 from http://tailforwin32.sourceforge.net/ and drag your logfile into it. It will monitor the file and reload it whenever it changes, so you can see what happens.

You can even add keywords to highlight lines that you are interested in, and even filter the output (if it becomes to verbose.)

The logfile can be used to investigate several different issues, from LDAP problems to connections to performance problems.

A word of caution, don't leave it on level ALL in a production environment, it will eat diskspace fast if you have many visitors. It should be set to WARN or ERROR in production to catch exceptions and warnings that might affect the site. Just don't forget to check the logfiles.

See http://logging.apache.org/log4net for more information on log4net.

Note! Be sure to check what version of log4net you have in your solution. EPiServer ships with a stable version of log4net, not the latest beta build. Some of the options and patterns might not be available in the version you are running with.

If you have problems deleting a log-file after for example a stresstest and do not want to kill the aspnet process you may have to add this setting in order to delete this file:

<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

The MinimalLock does not have optimal performance, but keeps locking to a minimum. Normally you do not need this setting.

EPiTrace logger