November Happy Hour will be moved to Thursday December 5th.

Local Logs are Nearly Always Empty

Vote:
 

We have a weird issue - our local logs on our development machines are empty (4 developers, all with the same problem). Of course my first thought was that our logging.config is incorrect but, here's the fun twist, suddnely, for one day, logging will work and the log for that day will have plenty of data. For example, we keep 14 days of logs - right now, 12 of mine are empty and 2 have data. We have consistent start up logging as well as logging we expect during development, so it's definitely not a case of nothing to log outside the days we're not working.

We have no issues in our test or prod environments - those log reliably. Maybe I am missing something, but our logging config (below) is pretty straightforward. Any thoughts?

<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"/>
    <!-- Enable MinimalLock to share log file, use with caution since logging will be considerably slower -->
    <!--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>

  <root>
    <!--Be careful, setting this value to All, Debug or Info will affect performance.-->
    <level value="Debug"/>
    <!--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>

#263939
Edited, Sep 27, 2021 16:11
valdis - Oct 04, 2021 9:07
if enable output debug appender - do you see data for that stream on days when log file is empty (you will need to run app for some time)?
Vote:
 

I tried the config above in an Alloy demo site, and I get statements in log file.

Did a quick test where I wrote to log from start page controller:

private readonly ILogger logger = LogManager.GetLogger(typeof(StartPageController));

        public ActionResult Index(StartPage currentPage)
        {
            logger.Error("This is logging message from start page");
....

#264218
Sep 30, 2021 14:18
Vote:
 

Mari,

I can also log fine from an Alloy demo site. No problems. I took the Alloy log config and used it in my site - no logging happens. 

It's so strange - the log file is always created. No issue there. I also have granted full control access to Everyone so there is no chance of permissions problems.

Today in messing with this, it started logging. I thought it had to do with changing the logging level to DEBUG as it was my last change. I changed the logging level from DEBUG to INFO, it stopped logging. I went back to DEBUG (I literallystopped the site, hit ctrl-z and started it again) and it still won't log.  It's just so strange. There is literally no rhyme or reason for why it behaves this way.

I also tried the very minimum logging config as shown here. It did start to work again so I began to add my other logging config lines 1-by-1 (like rollingStyle and datePattern). It stopps logging. I remove those, it still won't log.

Bottom line, there is seemingly no pattern for when it logs or doesn't. I'm beyond frustrated. The only pattern I can see is that this doesn't work on IIS Express. Our test and production sites log just fine with the exact same config. None of our developer sites log.

#265015
Oct 13, 2021 22:56
Vote:
 

Does youe site by any chance have log statements in global.asax.cs? I've previously seen that that will cause log isses.

#265048
Oct 14, 2021 6:09
Vote:
 

Have you tried upgrading EPiServer.Logging.Log4Net to the latest and greatest?

Are you using log4net directly or by Episerver's logging abstraction (private static readonly ILogger Logger = EPiServer.Logging.LogManager.GetLogger();)?

Sometimes log4net is not initialized correctly, and it fails to read configuration from EPiServerLog.config

Upgrading EPiServer.Logging.Log4Net usually solves the issue.

#265076
Oct 14, 2021 9:50
Vote:
 

Mari, nope no logging in the global.asax.cs.

Dejan, we are at the latest for EPiServer.Logging.Log4Net, however, I upgraded log4net from 2.0.8 to 2.0.12 and I HAVE CONSISTENT LOGGING!

I almost can't beleive it's real, I've launched my local site a dozen times to be sure it's not goign to stop :)

Thank you both for the nudges in the right direction.

#265087
Oct 14, 2021 21:18
Vote:
 

I would not give up :) What about if you run ProcessMonitor tool? Do you see that process is "touching" log file? I would also give a DebugView a try - to see if log4net is not emitting something on the debug output stream that might give you some clues what's going on..

#265353
Edited, Oct 20, 2021 7:24
- Oct 20, 2021 10:42
@Valdis, read above message one more time, especially part in capital letters ;)
valdis - Oct 20, 2021 11:28
blah, fast-read never worked
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.