Simplest way to programmatically write debug line to Episerver log

Vote:
 

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?

#131475
Jul 28, 2015 13:36
Vote:
 

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

How does your EPiServerLog.config file look like?

#131476
Jul 28, 2015 13:45
Vote:
 
<?xml version="1.0" encoding="utf-8"?>
<log4net>
    <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" />
        </layout>
    </appender>
    <appender name="outputDebugStringAppender" type="log4net.Appender.OutputDebugStringAppender" >
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="[%thread] %level %logger: %message%n" />
        </layout>
    </appender>

    <!-- Reduce amount of debug logging -->
    <logger name="EPiServer.Core.OptimisticCache" additivity="false">
        <level value="Error" />
    </logger>
    <logger name="EPiServer.Core.ContentProvider" additivity="false">
        <level value="Error" />
    </logger>
    <logger name="EPiServer.Data.Dynamic.Providers.DbDataStoreProvider" additivity="false">
        <level value="Error" />
    </logger>
    <logger name="EPiServer.Data.Providers.SqlDatabaseHandler" additivity="false">
        <level value="Error" />
    </logger>
    <logger name="EPiServer.Data.Providers.ConnectionContext" additivity="false">
        <level value="Error" />
    </logger>
    <logger name="EPiServer.Framework.Initialization">
      <level value="All" />
    </logger>
    <root>
        <!--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 (http://technet.microsoft.com/en-us/sysinternals/bb896647). -->
        <!--appender-ref ref="outputDebugStringAppender" /-->
    </root>
</log4net>

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

#131477
Jul 28, 2015 13:48
Vote:
 

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

#131478
Jul 28, 2015 13:51
Vote:
 

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

#131479
Jul 28, 2015 13:53
Vote:
 

No, single value.

I hope this blog post will help you: http://dcaric.com/blog/episerver-logging-and-troubleshooting-log4net

#131480
Jul 28, 2015 14:00
Vote:
 

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.. 

#131481
Jul 28, 2015 14:10
Vote:
 
  • DEBUG
  • INFO
  • WARN
  • ERROR
  • FATAL

If set DEBUG or ALL, everything will be logged.

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

#131482
Jul 28, 2015 14:14
Vote:
 

Thanks.. that's all i needed!

#131484
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.