log4net not working

I guess that either log4net is not logging at all, or the file is not ending up where you expect it.

Firstly, have you actually called

XmlConfigurator.Configure()

anywhere in your code? If the xml snippet above is in the application configuration file, this call will do the trick. If the xml snippet is in it's own file, you'll need to use the .Configure(string) overload that takes the path to the file. Without this call (or apparently the assembly level attribute mentioned by Kirk Woll), then log4net won't be logging at all.

If you believe this is all done, and log4net should be logging, then maybe you should put a fully qualified path in for the log file while you debug further. That will let you be sure where the file should be.


One gotcha for this type of thing is to make sure to add the XmlConfigurator attribute to the assembly by placing the following line in your AssemblyInfo.cs:

[assembly: log4net.Config.XmlConfigurator]

Otherwise log4net never activates.


There is another small gotcha, see here: http://logging.apache.org/log4net/release/manual/configuration.html#dot-config

the [assembly: log4net.Config.XmlConfigurator] method doesn't work with app.config. If you configure log4net from app.config, you must use the log4net.Config.XmlConfigurator.Configure() method.