From: <sv...@ca...> - 2005-12-28 11:11:58
|
User: hammett Date: 2005/12/28 06:05 AM Modified: /trunk/Facilities/Logging/Castle.Facilities.Logging/ LoggingFacility.cs /trunk/Services/Logging/Castle.Services.Logging.NLogIntegration/ NLogFactory.cs /trunk/Services/Logging/Castle.Services.Logging.log4netIntegration/ Log4netFactory.cs /trunk/Services/Logging/Castle.Services.Logging/ AbstractLoggerFactory.cs Log: Applied patch from Ahmed Ghandour <agh...@ry...> File Changes: Directory: /trunk/Facilities/Logging/Castle.Facilities.Logging/ =============================================================== File [modified]: LoggingFacility.cs Delta lines: +9 -4 =================================================================== --- trunk/Facilities/Logging/Castle.Facilities.Logging/LoggingFacility.cs 2005-12-27 17:20:28 UTC (rev 1519) +++ trunk/Facilities/Logging/Castle.Facilities.Logging/LoggingFacility.cs 2005-12-28 11:05:44 UTC (rev 1520) @@ -90,6 +90,7 @@ String typeAtt = FacilityConfig.Attributes["loggingApi"]; String customAtt = FacilityConfig.Attributes["customLoggerFactory"]; + String configFileAtt = FacilityConfig.Attributes["configFile"]; if (typeAtt != null) { @@ -97,12 +98,12 @@ converter.PerformConversion( typeAtt, typeof(LoggerImplementation) ); } - CreateProperLoggerFactory(logApi, customAtt); + CreateProperLoggerFactory(logApi, customAtt, configFileAtt); RegisterLoggerFactory(); } - private void CreateProperLoggerFactory(LoggerImplementation logApi, String customType) + private void CreateProperLoggerFactory(LoggerImplementation logApi, String customType, String configFile) { Type loggerFactoryType = null; @@ -152,7 +153,11 @@ } } - factory = (ILoggerFactory) Activator.CreateInstance(loggerFactoryType); + object[] args = null; + + if (configFile != null) args = new object[]{ configFile }; + + factory = (ILoggerFactory) Activator.CreateInstance(loggerFactoryType, args); } private void SetUpTypeConverter() @@ -162,4 +167,4 @@ } } -} \ No newline at end of file +} Directory: /trunk/Services/Logging/Castle.Services.Logging/ =========================================================== File [modified]: AbstractLoggerFactory.cs Delta lines: +17 -17 =================================================================== --- trunk/Services/Logging/Castle.Services.Logging/AbstractLoggerFactory.cs 2005-12-27 17:20:28 UTC (rev 1519) +++ trunk/Services/Logging/Castle.Services.Logging/AbstractLoggerFactory.cs 2005-12-28 11:05:44 UTC (rev 1520) @@ -21,7 +21,7 @@ public abstract class AbstractLoggerFactory : ILoggerFactory { - public AbstractLoggerFactory() + public AbstractLoggerFactory() { } @@ -50,24 +50,24 @@ /// <returns></returns> protected FileInfo GetConfigFile(string filename) { - FileInfo result; - if(IsWeb) - { - result = new FileInfo(HttpContext.Current.Request.PhysicalApplicationPath + filename); - } - else - { - result = new FileInfo(filename); - } + FileInfo result = new FileInfo(filename); +// if(IsWeb) +// { +// result = new FileInfo(HttpContext.Current.Request.PhysicalApplicationPath + filename); +// } +// else +// { +// result = new FileInfo(filename); +// } return result; } - private bool IsWeb - { - get - { - return HttpContext.Current != null; - } - } +// private bool IsWeb +// { +// get +// { +// return HttpContext.Current != null; +// } +// } } } Directory: /trunk/Services/Logging/Castle.Services.Logging.NLogIntegration/ =========================================================================== File [modified]: NLogFactory.cs Delta lines: +7 -3 =================================================================== --- trunk/Services/Logging/Castle.Services.Logging.NLogIntegration/NLogFactory.cs 2005-12-27 17:20:28 UTC (rev 1519) +++ trunk/Services/Logging/Castle.Services.Logging.NLogIntegration/NLogFactory.cs 2005-12-28 11:05:44 UTC (rev 1520) @@ -26,9 +26,13 @@ /// </summary> public class NLogFactory : AbstractLoggerFactory { - public NLogFactory() + public NLogFactory() : this ("nlog.config") + { + } + + public NLogFactory( string configFile ) { - FileInfo file = this.GetConfigFile("nlog.config"); + FileInfo file = GetConfigFile( configFile ); LogManager.Configuration = new XmlLoggingConfiguration(file.FullName); } @@ -43,4 +47,4 @@ throw new NotImplementedException("Logger levels cannot be set at runtime. Please review your configuration file."); } } -} \ No newline at end of file +} Directory: /trunk/Services/Logging/Castle.Services.Logging.log4netIntegration/ ============================================================================== File [modified]: Log4netFactory.cs Delta lines: +7 -3 =================================================================== --- trunk/Services/Logging/Castle.Services.Logging.log4netIntegration/Log4netFactory.cs 2005-12-27 17:20:28 UTC (rev 1519) +++ trunk/Services/Logging/Castle.Services.Logging.log4netIntegration/Log4netFactory.cs 2005-12-28 11:05:44 UTC (rev 1520) @@ -27,9 +27,13 @@ /// </summary> public class Log4netFactory : AbstractLoggerFactory { - public Log4netFactory() + public Log4netFactory() : this ("log4net.config") { - FileInfo file = this.GetConfigFile("log4net.config"); + } + + public Log4netFactory(string configFile) + { + FileInfo file = GetConfigFile(configFile); XmlConfigurator.ConfigureAndWatch(file); } @@ -44,4 +48,4 @@ throw new NotSupportedException("Logger levels cannot be set at runtime. Please review your configuration file."); } } -} \ No newline at end of file +} |