Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Error logging with Log4Net is not working in production.

Vote:
 

In production environment metods like 'logger.Error("Some error message")' creating a 'EPiServerErrors.log' , but the message text is not written to. We are getting only empty files only. What can be the cause for this issue?. In our local host everything working fine.We are using Episerver version 11.Our configuration:

<?xml version="1.0" encoding="utf-8"?>
<log4net>
<!-- 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>

<root>
<!--Be careful, setting this value to All, Debug or Info will affect performance.-->
<level value="Error"/>
<appender-ref ref="errorFileLogAppender"/>
</root>
<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"/>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<appendToFile value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %level %logger: %message%n"/>
</layout>
</appender>
</log4net>

#207239
Edited, Sep 14, 2019 3:43
Vote:
 

Note that log4net is not working on Azure (therefore DXC) if you are using that

If you are not, then make sure your apppool has write access to log folder

#207240
Sep 14, 2019 9:23
Vote:
 

Hi Quan, 

Thanks for quick response, as we can see an empty file generated each day , means the folder (in our case App_Data) is having access to wrire a text file. As you mentioned that  "log4net is not working on Azure" , yes we are using log4net only. Can you suggest any other way for logging in episerver that will work on Azure (therefore DXC) .

#207241
Sep 14, 2019 12:20
Vote:
 

Application insight works well. There is also a log4net appender to it that you can use

#207242
Sep 14, 2019 13:45
Janakiram - Sep 14, 2019 14:00
Thanks Daniel.
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.