Log4net
  1. Log4net
  2. LOG4NET-277

Registering a custom Object Renderer in configuration file

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Not A Problem
    • Affects Version/s: 1.2.10
    • Fix Version/s: 1.2.12
    • Component/s: Other
    • Labels:
      None
    • Environment:
      Windows .Net WebService

      Description

      When you include the line:

      <renderer renderingClass="RootNameSpace.Namespace.RendererClass" renderedClass="RootNameSpace.NameSpace.ClassToRender" />

      in the configuration file and call:

      log4net.Config.XmlConfigurator.ConfigureAndWatch(New IO.FileInfo(logfile))

      in global.asax, you get a TypeLoadException. Log4Net internal debugging outputs the following:

      log4net:ERROR OptionConverter: Could not instantiate class [LogLibrary.Log4NetObjRenderers.PdaLogObjRenderer].
      System.TypeLoadException: Could not load type [LogLibrary.Log4NetObjRenderers.PdaLogObjRenderer]. Tried assembly [log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821] and all loaded assemblies
      at log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase) in c:\work\svn_root\apache\log4net\tags\log4net-1.2.10-rc2\build\package\log4net-1.2.10\src\Util\SystemInfo.cs:line 671
      at log4net.Util.SystemInfo.GetTypeFromString(String typeName, Boolean throwOnError, Boolean ignoreCase) in c:\work\svn_root\apache\log4net\tags\log4net-1.2.10-rc2\build\package\log4net-1.2.10\src\Util\SystemInfo.cs:line 602
      at log4net.Util.OptionConverter.InstantiateByClassName(String className, Type superClass, Object defaultValue) in c:\work\svn_root\apache\log4net\tags\log4net-1.2.10-rc2\build\package\log4net-1.2.10\src\Util\OptionConverter.cs:line 477
      log4net:ERROR XmlHierarchyConfigurator: Could not instantiate renderer [LogLibrary.Log4NetObjRenderers.PdaLogObjRenderer].

      Work Around:

      1, If you then stop the web server
      2, and comment out the <renderer line in the configuration file,
      3, start the web service again,
      4, then after it has started (global.asax has been processed)
      5, uncomment the <renderer line
      6, the renderer will now work

        Activity

        Hide
        Daniel Shoubridge added a comment - - edited

        I found a work around:

        include ", RootNameSpace":

        i.e.

        Change
        <renderer renderingClass="RootNameSpace.Namespace.RendererClass" renderedClass="RootNameSpace.NameSpace.ClassToRender" />
        to
        <renderer renderingClass="RootNameSpace.Namespace.RendererClass, RootNameSpace" renderedClass="RootNameSpace.NameSpace.ClassToRender, RootNameSpace" />

        I can't say why this works, but looks like it helps log4net find the assembly.

        Show
        Daniel Shoubridge added a comment - - edited I found a work around: include ", RootNameSpace": i.e. Change <renderer renderingClass="RootNameSpace.Namespace.RendererClass" renderedClass="RootNameSpace.NameSpace.ClassToRender" /> to <renderer renderingClass="RootNameSpace.Namespace.RendererClass, RootNameSpace" renderedClass="RootNameSpace.NameSpace.ClassToRender, RootNameSpace" /> I can't say why this works, but looks like it helps log4net find the assembly.
        Hide
        Stefan Bodewig added a comment -

        Does your appender live in RootNameSpace.dll?

        Show
        Stefan Bodewig added a comment - Does your appender live in RootNameSpace.dll?
        Hide
        Dominik Psenner added a comment -

        As pointed out in a previous comment: when one references a class from another assembly, one has to specify the assembly where it is located.

        Show
        Dominik Psenner added a comment - As pointed out in a previous comment: when one references a class from another assembly, one has to specify the assembly where it is located.

          People

          • Assignee:
            Dominik Psenner
            Reporter:
            Daniel Shoubridge
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development