1

I am trying to set the location of my log4net.config file programmaticly in my C# project, using .net 4.0 and v1.2.11 of log4net, like it is defined here. It looks straight forward enough but whenever I try to use the XmlConfigurator.Configure methid I get the following error:

Error 4 'log4net.Config.XmlConfigurator.Configure(log4net.Repository.ILoggerRepository, System.IO.Stream)' is a 'method' but is used like a 'type'

This is the line of code that is causing the problem:

XmlConfigurator.Configure(new System.IO.FileInfo(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\LocatorConfig.xml"));

Any help with this would be appreciated. Anto

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Anto
  • 419
  • 2
  • 9
  • 19
  • What's the problem here? your code works perfectly ... anyway if I were you I would try using the Configure() overload that takes a Uri instead ... – Omri Btian Sep 12 '13 at 08:59
  • 1
    Could you provide the complete code of the function containing this line ? It might be a syntax error on the preceding line or something like this. – Marshall777 Sep 12 '13 at 09:09
  • @Omribitan The problem is that it doesn't work perfectly. – Anto Sep 12 '13 at 09:59
  • @Marshall777 The only code before the XmlConfigurator call is the definition of a public class that inherits the interface ESRI.ArcGIS.Geoprocessing.IGPFunction – Anto Sep 12 '13 at 10:01
  • @Omribitan Then just copy and paste the whole code file content as it won't be too long. I can't see anything else than a syntax error to justify the compilation error you mentioned. – Marshall777 Sep 12 '13 at 13:19
  • I still don't know what caused this issue, it still occurs only in this class, but adding a wrapper like suggested in [this post](https://stackoverflow.com/questions/1028375/how-do-you-configure-and-enable-log4net-for-a-stand-alone-class-library-assembly) has helped with my issue. – Anto Sep 12 '13 at 10:36

0 Answers0