Whats wrong with my log4net configuration?
I have an ASP.NET MVC app which has a bootstrapper class that configures log4net during application startup as follows:
public static void Configure(IApplicationContext applicationContext)
{
var appender = new log4net.Appender.FileAppender
{
Layout = new log4net.Layout.PatternLayout("%d [%t]%-5p %c [%x] <%X{auth}> - %m%n"),
File = applicationContext.GetLogFile().FullName
};
BasicConfigurator.Configure(appender);
}
I have checked that when I call the logging function later that the repository is configured:
LogManager.GetRepository().Configured
this returns true.
The location of applicationContext.GetLogFile().FullName
exists and also has permissions set for any user to be able to create and modify files, so I don't quite understand why this fails to create a log file or output any data.
Now I know you can use config files and XML in the Web.config but because the log file location开发者_开发问答 and configuration will change from site to site I need to do this in code.
Please can someone help me.
you should add an
appender.ActivateOptions();
精彩评论