I have a console application and have a class library which wraps the Log4Net methods. Now when run the application in debug mode it writes log but when it is built in relea
There are a few workarounds for this.
You could add the [MethodImpl(MethodImplOptions.NoInlining)]
attribute to your Logger constructor methods in your class library.
You could add [assembly: log4net.Config.XmlConfigurator(Watch =
true)]
to AssemblyInfo.cs in your Console Project (not the class library project)
You can add log4net.Config.XmlConfigurator.Configure();
at the
start of your Logger constructor.
I think the reason this is happening is that in release mode, your class library is inlined and so when log4net attempts to find the attribute, it thinks the calling assembly is your exe which does not contain the attribute.
PS.
I presume you are aware that your Logger class will mean that you lose the ability to filter by method names, as log4net will only see the Logger.Info method name.