Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Simplest way to programmatically write debug line to Episerver log


Hey Guys,

i'm using this:

private static readonly ILogger Logger = LogManager.GetLogger();
Logger.Debug(string.Format("CacheManager - TEST"));    

But it is not written in the EPiServer log located in the app_data folder... 

Is this not the correct way to do this?

Jul 28, 2015 13:36

Can you set a breakpoint on Logger.Debug(...) and check if Logger.IsDebugEnabled returns true?

How does your EPiServerLog.config file look like?

Jul 28, 2015 13:45
<?xml version="1.0" encoding="utf-8"?>
    <appender name="errorFileLogAppender" type="log4net.Appender.RollingFileAppender" >
        <!-- Consider moving the log files to a location outside the web application -->
        <file value="App_Data\EPiServerErrors.log" />
        <encoding value="utf-8" />
        <staticLogFileName value="true"/>
        <datePattern value=".yyyyMMdd.'log'" />
        <rollingStyle value="Date" />
        <threshold value="Error" />
        <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
        <appendToFile value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date [%thread] %level %logger: %message%n" />
    <appender name="outputDebugStringAppender" type="log4net.Appender.OutputDebugStringAppender" >
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="[%thread] %level %logger: %message%n" />

    <!-- Reduce amount of debug logging -->
    <logger name="EPiServer.Core.OptimisticCache" additivity="false">
        <level value="Error" />
    <logger name="EPiServer.Core.ContentProvider" additivity="false">
        <level value="Error" />
    <logger name="EPiServer.Data.Dynamic.Providers.DbDataStoreProvider" additivity="false">
        <level value="Error" />
    <logger name="EPiServer.Data.Providers.SqlDatabaseHandler" additivity="false">
        <level value="Error" />
    <logger name="EPiServer.Data.Providers.ConnectionContext" additivity="false">
        <level value="Error" />
    <logger name="EPiServer.Framework.Initialization">
      <level value="All" />
        <!--Be careful, setting this value to All, Debug or Info will affect performance.-->
        <level value="Error" />

        <!--Enabled file logging-->
        <appender-ref ref="errorFileLogAppender" />

        <!-- Use DebugView (Microsoft/SysInternals) and enable Capture Win32 + Capture Global Win32 ( -->
        <!--appender-ref ref="outputDebugStringAppender" /-->

That is my episerver.log  and Logger.IsDebugEnabled() return false ... what am i missing?

Jul 28, 2015 13:48

On line 10, you have threshold value="Error" which means that Info, and Debug messages won't be logged.

Jul 28, 2015 13:51

Is that a comma seperated field... If i want the debug messages to be logged as well do i write  threshold value="Error,Debug" ?

Jul 28, 2015 13:53

No, single value.

I hope this blog post will help you:

Jul 28, 2015 14:00

thanks good info...

there you say that "If we open EPiServerLog.config file, we'll see that threshold value is set to Error. This means that only Error (and higher level) messages will be logged."

What is the level structure. So if i add Debug, will Error also be logged?

What is the correct level sequence. Because if i add Debug, i want Error also to be logged.. 

Jul 28, 2015 14:10
  • INFO
  • WARN

If set DEBUG or ALL, everything will be logged.

If you set ERROR, only ERROR and FATAL will be logged.

Jul 28, 2015 14:14

Thanks.. that's all i needed!

Jul 28, 2015 14:16
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.