Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mikkel Fennestad 5 posts 55 karma points
    Feb 20, 2013 @ 17:42
    Mikkel Fennestad
    0

    Problems with different versions of log4net

    Hello,

    I've got an existing Class Library with a lot of functionality and business logic, that I'm trying to integrate with a clean install of Umbraco 6.0.

    Unfortunately, some of the external dlls that we're using are relying on log4net version 1.2.10.0 and Umbraco 6.0 uses log4net version 1.2.11.0...

    I tried the simple fix of replacing the dlls. When replacing the log4net.dll in the Umbraco/bin dir with the old version, we get this error when starting up the website:

    "Could not load file or assembly 'log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies."

    When using the new version of log4net Umbraco works, but the page calling a method in our class library will fail with:

    "Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=be58efc3b934219b' or one of its dependencies."

    I've tried this solution: http://stackoverflow.com/questions/2460542/using-different-versions-of-the-same-assembly-in-the-same-folder

    But for some reason this doesn't work for me. Is there another way of doing the same when running a website or am I missing something?

    Does anybody have any tips on this or have had a similar problem?

    Thanks,

    Mikkel

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 20, 2013 @ 23:33
    Jan Skovgaard
    0

    Hi Mikkel and welcome to our :)

    Did you add the 1.2.11.0 log4net as a reference in your project and recompile it afterwards? We've been doing this on projects where we have been using an older version of the log4net.dll file, which worked fine.

    Looking forward to hearing from you.

    /Jan

  • Mikkel Fennestad 5 posts 55 karma points
    Feb 22, 2013 @ 11:02
    Mikkel Fennestad
    0

    Hi Jan,

    Thanks for your answer :)

    No, I added Umbraco to my project using the package manager console. So I guess it's the binary distribution, and my feeble attempts at adding references to different versions of log4net have not been compiled into the project...

    A pointer to how to get a compileable version and build it? :)

    Thanks,

    Mikkel

  • Mikkel Fennestad 5 posts 55 karma points
    Feb 28, 2013 @ 10:16
    Mikkel Fennestad
    100

    OK a quick follow up:

    I tried adding log4net 1.2.10 to my Umbraco project and compile it. The result is that Umbraco will not start because it cannot find log4net 1.2.11.

    An important point: In my class library we're using a third party component that is using 1.2.10, so I have no way of recompiling that to use 1.2.11 -- we're stuck with 1.2.10 :(

    Is there no way to have both versions exist in the same project?

    Thanks,

    Mikkel

  • Mikkel Fennestad 5 posts 55 karma points
    Feb 28, 2013 @ 14:41
    Mikkel Fennestad
    0

    Final follow up :o)

    The solution I linked to in the very first entry in this thread actually worked. I just couldn't see it, as I was fooled by Apache changing its public key token on the DLLs, which gives the same error message...

  • Ricardo 24 posts 56 karma points
    Jul 19, 2013 @ 14:00
    Ricardo
    0

    Was having the same problem with Log4Net and finally found the cause. In my project downloaded Log4Net from the Apache site (http://logging.apache.org/log4net/) and copied the log4Net.DLL in folder log4net-1.2.11-bin-newkey\log4net-1.2.11\bin\net\4.0\release. This DLL is the same version 1.2.11.0 but noticed has different file size to the one that comes with Umbraco 6 installation. 

    Solution, instead using the one from the Apache site, went back to use the one in Umbraco and problem solved.

    Don't understand why the DLLs are different being 1.2.11 and both NET Framework 4.0. Any ideas?

     

  • Mikkel Fennestad 5 posts 55 karma points
    Jul 19, 2013 @ 14:18
    Mikkel Fennestad
    0

    While I struggled with this problem, I found this page:

    http://stackoverflow.com/questions/8743992/how-do-i-work-around-log4net-keeping-changing-publickeytoken

    I don't know if it gives any clear answers to why Apache decided to change the publickeytoken, but it's the best I could find :o)

  • Ricardo 24 posts 56 karma points
    Jul 19, 2013 @ 15:31
    Ricardo
    0

    Thanks for the reply. Did not find any reference to the log4Net publicKeyToken in Umbraco thats why did not try with the old key DLL.

    But it is curious that Umbraco log4Net.dll is 252KB and the one from Apache is 282KB. 

    We'll need to wait for the good Umbraco people to compile with the DLL with the new key.

     

     

     

     

  • Paul Stoker 39 posts 72 karma points c-trib
    Aug 18, 2013 @ 17:00
    Paul Stoker
    0

    Hi Guys,

    I'm experiencing the same issue. I have a domain project which relies on Castle Windsor to inject the log4net facility into my code and this relies on log4net 1.2.10 but Umbraco is using, what seems to be a patched version of 1.2.11.

    Can any of the Umbraco experts shed some light why Umbraco has a patched version of log4net?

    So far I've tried:

    Redirecting all assemblies to 1.2.11 from Umbraco installation but it won't work as the patched version has a null public key token
    Forking castle core log4net integration to use the umbraco patched log4net assembly which won't build as it doesnt have a Strong Name

    Does anyone have any other ideas?

  • Jerode 44 posts 159 karma points
    Aug 18, 2013 @ 18:46
    Jerode
    0

    I am not an expert but it may be that the log4net version Umbraco is using has some customizations like a Medium trust. I would be interested in hearing from some experts on this as well.

  • Paul Stoker 39 posts 72 karma points c-trib
    Aug 18, 2013 @ 20:40
    Paul Stoker
    1

    Thanks Jerode,

    For now I've managed to get things working by adding a code base redirect to the web.config for Castle Windsor log4net integration to work:

    <dependentAssembly>
            <assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" />
            <codeBase version="1.2.10.0" href="bin\log4net.1.2.10\log4net.dll" />
    </dependentAssembly>

    And then adding a second appender in the log4net.config file which logs all the custom code:

    <?xml version="1.0"?>
    <log4net>
        <root>
            <priority value="Info"/>
            <appender-ref ref="AsynchronousLog4NetAppender" />
        <appender-ref ref="RollingFile" />
        </root>

        <!--To Change the way logging works for certain namespaces, insert a new logger like: -->
        <!--
        <logger name="Umbraco.Core">
            <level value="WARN" />
        </logger>-->

        <appender name="AsynchronousLog4NetAppender" type="Umbraco.Core.Logging.AsynchronousRollingFileAppender, Umbraco.Core">
            <file value="App_Data\Logs\UmbracoTraceLog.txt" />
            <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
            <appendToFile value="true" />
            <rollingStyle value="Date" />
            <maximumFileSize value="5MB" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
            </layout>
        </appender>

      <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
        <file value="App_Data\Logs\WebsiteUpd8.log" />
        <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
        <appendToFile value="true" />
        <rollingStyle value="Date" />
        <maximumFileSize value="5MB" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
        </layout>
      </appender>
     
    </log4net>

    Now I can use the Castle.Core.Logging facility feature and install it as follows:

    using Castle.Facilities.Logging;
    using Castle.MicroKernel.Registration;
    using Castle.MicroKernel.SubSystems.Configuration;
    using Castle.Windsor;

    namespace WebsiteUpd8.Website.Installers
    {
        public class LoggerInstaller : IWindsorInstaller
        {
            public void Install(IWindsorContainer container, IConfigurationStore store)
            {
                container.AddFacility<LoggingFacility>(f => f.UseLog4Net());
            }
        }
    }
  • Haansi 51 posts 150 karma points
    Sep 26, 2014 @ 05:50
    Haansi
    0

    How I solved.

    Did 3 things:

    1. Removed all instances of Log4net from all projects (MVC and class libraries) and copy one comes with UmbracoCMS installation.

    2. Removed all temp files in all projects

    3. Removed previous references of all other class libraries which were using Log4net, built them again and then added references into web project.

Please Sign in or register to post replies

Write your reply to:

Draft