So far the most concise way to configure Windsor's logging facility is:
var ioc = new WindsorContainer();
ioc.AddFacility("logging", new
LoggingFacility(LoggerImplementation.Log4net));
With this configuration, log4net configuration is expected in
"log4net.config" file under current appdomain folder. I can configure file
with this overload:
ioc.AddFacility("logging", new LoggingFacility(LoggerImplementation.Log4net,
"log4net.cfg.xml"));
However, if i want to put log4net configuration in Web.config/App.config,
the only way i found is this:
public class Log4NetLoggerFactory : Log4netFactory
{
public Log4NetLoggerFactory()
{
XmlConfigurator.Configure();
}
}
ioc.AddFacility("logging", new
LoggingFacility(typeof(Log4NetLoggerFactory).AssemblyQualifiedName, ""));
Is there another way to do this?
Is there a reason for not supporting this? Something as simple as this can
be sufficient:
namespace Castle.Services.Logging.Log4netIntegration
{
public class Log4netFactory : AbstractLoggerFactory
{
public Log4netFactory() : this("log4net.config")
{
}
public Log4netFactory(String configFile)
{
if(configFile == "")
{
XmlConfigurator.Configure();
}
else
{
FileInfo file = GetConfigFile(configFile);
XmlConfigurator.ConfigureAndWatch(file);
}
}
...
--
Gian Marco Gherardi
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.