Loading...
Area: Episerver Search & Navigation
Applies to versions: 12 and higher
Other versions:

Logging

Recommendations [hide]

To investigate and resolve issues, it is recommended to turn on logging for your application. This topic describes logging for an integrated solution with Episerver Search & Navigation (formerly Episerver Find) and Episerver CMS.

How it works

The Logging API shipped with Episerver is an abstraction for writing log messages from the system, and is used internally by the Episerver assemblies for all logging. 

When creating new CMS sites using the Episerver Visual Studio integration, the package EPiServer.Logging.Log4Net is installed by default, which is the log4net implementation of the API. Episerver Search & Navigation also uses the log4net framework. 

Activating logging

To activate logging, add an appender and a logger in the EPiServerLog.config, located by default in the web root of your Episerver application, for the EPiServer.Find namespace.

<appender name="FindRollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
   <file value="find.log" />
   <appendToFile value="true" />
   <datePattern value=".yyyyMMdd.'log'" />
   <rollingStyle value="Date" />
   <filter type="log4net.Filter.LevelRangeFilter">
      <acceptOnMatch value="true" />
      <levelMin value="INFO" />
      <levelMax value="FATAL" />
   </filter>
   <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date %level [%thread] %type.%method - %message%n" />
   </layout>
</appender>
<logger name="EPiServer.Find">
   <appender-ref ref="FindRollingLogFileAppender" />
</logger>

If your application does not have an EPiServerLog.config, create one in your application's web root folder and add the logger and appender there.

<?xml version="1.0" encoding="utf-8"?>
<log4net>
<appender name="FindRollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
   <file value="find.log" />
   <appendToFile value="true" />
   <datePattern value=".yyyyMMdd.'log'" />
   <rollingStyle value="Date" />
   <filter type="log4net.Filter.LevelRangeFilter">
      <acceptOnMatch value="true" />
      <levelMin value="INFO" />
      <levelMax value="FATAL" />
   </filter>
   <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date %level [%thread] %type.%method - %message%n" />
   </layout>
</appender>
<logger name="EPiServer.Find">
   <appender-ref ref="FindRollingLogFileAppender" />
</logger>
</log4net>

Related topic

Do you find this information helpful? Please log in to provide feedback.

Last updated: Oct 31, 2016

Recommendations [hide]