Clog and .Net 4.0

Apr 20, 2010 at 8:32 PM


I get an exception I don´t know how to get past. Maybe it is just a newbie exception. The exception is from a .Net 4.0 Web Site. I´m using log4net and have got the configuration from the examples provided. The exception I get is:

System.TypeInitializationException was unhandled by user code
  Message=The type initializer for 'DanielVaughan.Logging.Log' threw an exception.
       at DanielVaughan.Logging.Log.Info(String message)
       at MediaLibraryLogging.Presentation._Default.Page_Load(Object sender, EventArgs e) in <path-to-website>\Default.aspx.cs:line 17
       at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException: System.ArgumentNullException
       Message=Value cannot be null.
Parameter name: key
            at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
            at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
            at DanielVaughan.Logging.Configuration.LogRepository.Load(XmlElement rootElement)
            at DanielVaughan.Logging.Log.InitFromConfig()
            at DanielVaughan.Logging.Log..cctor()

Does someone know what to do with this?



Apr 20, 2010 at 8:38 PM

Hi Fredrik,

Could you post your Clog config section please.



Apr 20, 2010 at 9:01 PM

In web.config I have:

    <section name="Clog" type="DanielVaughan.Logging.Configuration.ClientLoggingConfigurationSectionHandler, DanielVaughan.Logging"/>


    <!-- InternalLogLevel is used to monitor log messages originating from Clog,
    and which are written to the console. Valid values are (from less to most restrictive):
    All, Debug, Info, Warn, Error, Fatal, None. -->
    <Clog InternalLogLevel="All" xmlns="">
      <LogStrategy Name="Log4Net" Type="DanielVaughan.Logging.LogStrategies.Log4NetStrategy, DanielVaughan.Logging.Log4NetLogStrategy">
        <Filter Name="IPAddressRange" Type="DanielVaughan.Logging.Filters.IPAddressRangeFilter, DanielVaughan.Logging" Begin="" End=""/>
        <!-- Uncomment to prevent access to those users that do now have membership of the specified roles. -->
        <!-- <Filter Name="RoleMembership" type="DanielVaughan.Logging.Filters.RoleMembershipFilter, DanielVaughan.Logging" Roles="Developer, Administrator" /> -->


Apr 20, 2010 at 9:03 PM

Try commenting out the IPAddressRange filter.


Apr 20, 2010 at 9:11 PM

Thanks for the really fast response but I still got the same error message unfortunately.

Apr 20, 2010 at 9:16 PM

Fredrik, are you using the latest version from ?

Apr 20, 2010 at 9:25 PM

I'm using v.1.10 from and it works now! :-) It took a few restarts of the website but now it works. I tried enabling IPAddressRange to see if that was the problem (I don´t currently need it) and it was, it stopped working again. Thanks again for all help.

Apr 20, 2010 at 9:32 PM

I think it may be an IPv6 issue. I'll look into it. Glad it's now working for you.




Apr 21, 2010 at 7:25 AM

Hmm, maybe I was to quick shouting out that it worked. Well, it is working on the server side. But when I try to log on the client side I get a error message in the server side services. It seems like the configuration still isn't loaded correctly.

The type initializer for 'DanielVaughan.Logging.Log' threw an exception.

System.TypeInitializationException, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

System.ArgumentNullException, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

DanielVaughan.Logging.Log.GetLogLevel(IClientInfo info)
DanielVaughan.Logging.ClogService.GetConfiguration(IClientInfo clientInfo)
SyncInvokeGetConfiguration(Object , Object[] , Object[] )

Apr 22, 2010 at 7:47 AM

Somehow it doesn't read the configuration when the getConfiguration request come from the client. I get "Clog Error:LogStrategy is missing or of wrong type. Name: System.Configuration.ConfigXmlAttribute" .

Apr 22, 2010 at 2:03 PM

Sorry about these posts, it was a bug in my environment. My project had lost the reference to the DanielVaughan.Logging.Log4NetLogStrategy.dll. I'm don't know why though. But when I added it again it started working on both server and client.

Thanks for a great product,

// Fredrik

Apr 22, 2010 at 2:21 PM

Glad you got it sorted Fredrik. Thanks for letting me know.