3

I have a CD environment in a two-CD cluster running Sitecore 8.1u2, and today I noticed that my CD2 environment is not writing to its logs, even though it is running exactly as expected.

I verified the following:

  • CD1 and the CM are all writing to their logs, as expected
  • The site is still running and I do not have any relevant errors in the Event Viewer
  • Permissions have been assigned correctly (triple-checked and had a peer verify, as well)

UPDATE

  • The Data folder is configured correctly and is not being overridden (in response to @OwenNiblock's comments)
  • The LogFileAppender is set to the correct path (in response to @DerekC's answer)

I feel like I'm going crazy and that there is something ridiculously simple that I'm missing. Does anyone know what could cause logs to suddenly stop writing without error, and know how to fix it?

  • Have you checked "showconfig" to see if the data directory location is being overridden somewhere? – Owen Niblock Nov 8 '16 at 16:38
  • Against all odds, but is there any traffic on CD2? – Thomas D Nov 8 '16 at 16:38
  • I did check, and the Data directory is specified correctly and not overridden. I will update the OP with that check @OwenNiblock. That's still a good catch ;) – Zachary Kniebel Nov 8 '16 at 16:39
  • @ThomasD there is no "real" traffic at present. I am currently getting these environments ready for production. However, I am actively testing, so if traffic from me, alone, counts.... – Zachary Kniebel Nov 8 '16 at 16:39
  • 1
    @Gatogordo for the win! I searched for "reset log4net sitecore" and found a John West post that linked to an old SDN article called "Wake up log files". Apparently this is a known issue. All I had to do was create the described ASPX and hit it and the logs started writing again. I'll post an answer – Zachary Kniebel Nov 8 '16 at 16:53
2

@Gatogordo's "try turning it off and back on" suggestion did the trick. I found John West's All About Logging with Sitecore ASP.NET CMS blog post, which led me to an old SDN article, aptly named Wake up log files.

The article poses the following problem:

Occasionally after application restart log files are not working. How can I fix this without making a second restart?

As a solution, the article instructs you to create an ASPX file with the following contents:

<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        log4net.LogManager.ResetConfiguration();
        log4net.Config.DOMConfigurator.Configure();
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Log wake up</title>
</head>
<body>
Done.
</body>
</html>

What this is doing is reloading the log4net configuration, essentially turning it off and back on again.

I added this to my site root, hit it from the browser and behold! I had log files! Thanks @Gatogordo!

1

Some other things worth checking in your configs via /sitecore/admin/showconfig.aspx:

Data Folder is set properly:

<sc.variable name="dataFolder" value="C:\inetpub\wwwroot\sxa82\Data"/>

Check the appender node to make sure the path is correctly compiling to the right path:

<appender name="LogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
 <file value="C:\\inetpub\\wwwroot\\sxa82\\Data/logs/log.{date}.txt"/>
 <appendToFile value="true"/>
 <layout type="log4net.Layout.PatternLayout">
  <conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n"/>
 </layout>
 <encoding value="utf-8"/>
</appender>
  • Ah, disregard. Just saw you edited and checked it. Still might be worth checking the appender. – Derek C Nov 8 '16 at 16:44
  • All checked and accounted for, but still +1 because this might help others :) – Zachary Kniebel Nov 8 '16 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.