Join our community!

Get everything you need to start developing EPiServer solutions.

Log4Net troubles

December 3 2009, 16:31

We are currently experiencing some issues with getting error logging to work at a client site. We have both tried the default EPiServerLog.config that comes with the default install and replacing the file with the simpler one listed here http://world.episerver.com/en/Documentation/Items/Tech-Notes/EPiServer-CMS-5/EPiServer-CMS-SP2/Logging-in-EPiServer-CMS-5/#_Toc136766750 
Our problem is that nothing is written to the log file. That is…the logfile is created but no log entries end up in the log. 
Any tips on how to trouble shoot this?

We are currently experiencing some issues with getting error logging to work at a client site. We have both tried the default EPiServerLog.config that comes with the default install and replacing the file with the simpler one listed here http://world.episerver.com/en/Documentation/Items/Tech-Notes/EPiServer-CMS-5/EPiServer-CMS-SP2/Logging-in-EPiServer-CMS-5/#_Toc136766750 


Our problem is that nothing is written to the log file. That is…the logfile is created but no log entries end up in the log. 
Any tips on how to trouble shoot this?


  • December 4 2009, 11:06

    Make sure that you don't have more then one log4net-log running at the same time. I've seen this behavior when I was using Composer and the dropit.extension.config in the bin folder and was trying to get the ordinary episerver log to run.

  • December 7 2009, 9:39

    Use Debug View from System Internals to see what log4net logs during start-up. Also make sure you do not define a class wide logger (typically ILog _log in global.asax.cs).

    Also see "How do I enable log4net internal debugging?" on: http://logging.apache.org/log4net/release/faq.html

    /Steve

  • December 7 2009, 11:00

    I  had the same problem with a faulty custom made Page Provider.

  • December 8 2009, 17:37

    Thanks for your replies. I found a class logger in the global.asax which I removed. but still there seems to be a problem with something hold on to the logfile. Might there also be a problem with class loggers in files deriving from EPiServer.PlugIn.PlugInAttribute?

  • December 8 2009, 17:48

    Do you have classes inheriting from that attribute? Why?

    Would not think that having loggers in such a class should give you problems. Did you get any results from the internal debugging? Have you tried System Internals Debug View? Any problems parsing logging config files should show up there.

    Does your global class inherit from EPiServer.Global?

    Btw. you should not have any log4net configurations in web.config at all. EPiServer hooks up log4net using an attribute in episerver.dll.

  • December 8 2009, 18:03

    We use the class deriving from that attribute to run some code when the site is  starting. se this link http://labs.episerver.com/en/Blogs/Allan/Dates/112230/3/When-and-Where-to-attach-DataFactory-Event-Handlers/. From the debug information from log4net we found that there was a problem that something has a lock on the file ...And that something seems to be the application. So now we just need to figure out where :) 

    Our global inherits EPiServer.Global... and the trick with stuffing the log4net configuration in the web.config file has worked sometimes on other sites where logging stopped working... don't know why tho

  • December 8 2009, 18:12

    Hm,
    you have the episerver.dll in you bin folder (in addition to GAC)?

    Is this an enterprise site? Are there more than one site pointing to the same place on disk (using the same episerverlog.config)?

  • December 11 2009, 15:55
    Content is edited

    Thats about the same as Steve suggested above...

     

    Removing the class logger from the classes deriving from PlugInAttribute seemed to get things working again. 

    Cheers for all help and insight! 

  • September 6 2012, 8:42
    Content is edited

    I also have issues with log4net, but little bit different. log4net logs everything, but not my custom classes. Tried to explicitly configure logger to log my namescpace:

    <logger name="My.Website.Business">
        <level value="All" />
    </logger>

    I am defining logger in my custom class like this:

    ILog log = LogManager.GetLogger(typeof(MyClass));

    And call it:

    log.Error("Some error");

    I also enabled log4net logging itself to see what happens on startup, but there are no errors or strange behaviour. It even creates logger defined in config. I also tried to define other appender for my logger, but it just creates empty file and doesn't log anything.

    I have other 3d party components in project like NHibernate and those logs fine to same log.

  • January 10 2013, 21:24

    My issue with log4net was related to different log4net versions between my application and EPiServer. EPiServer uses 1.2.10, but I had upgraded log4net to 1.2.11 (2.0) which are not compatible. So EPiServer logs fine, but my application didn't log anything. After downgrading log4net logging started to work fine.

  • April 19 2013, 14:42

    I had same issue and thanks to Maris it is now resolved. We updated to latest log4net midway through a project. This explains why logging suddenly stopped working.