[jira] Created: (LOG4NET-37) Allow the RepositorySelector type to be sepecified using the AppSettings config
Allow the RepositorySelector type to be sepecified using the AppSettings config --- Key: LOG4NET-37 URL: http://issues.apache.org/jira/browse/LOG4NET-37 Project: Log4net Type: New Feature Components: Core Versions: 1.2.9 Reporter: Nicko Cadell Assigned to: Nicko Cadell Priority: Minor Fix For: 1.2.10 Allow the RepositorySelector type to be sepecified using the AppSettings config. The RepositorySelector is set by default to be DefaultRepositorySelector. This can be changed programatically by setting the LoggerManager.RepositorySelector property, however it cannot be set at runtime via the application configuration files. Propose adding an AppSettings property 'log4net.RepositorySelector' that can be set to the type name of the repository selector to load. If this property is missing, or the type cannot be created the current default behaviour will continue. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
cvs commit: logging-log4net/src/Core LoggerManager.cs
nicko 2005/06/21 12:11:57 Modified:src/Core LoggerManager.cs Log: Fix for LOG4NET-37. Allow the RepositorySelector type to be sepecified using the AppSettings config Revision ChangesPath 1.9 +65 -3 logging-log4net/src/Core/LoggerManager.cs Index: LoggerManager.cs === RCS file: /home/cvs/logging-log4net/src/Core/LoggerManager.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- LoggerManager.cs 17 Jan 2005 20:18:43 - 1.8 +++ LoggerManager.cs 21 Jun 2005 19:11:57 - 1.9 @@ -17,7 +17,7 @@ #endregion using System; -using System.Collections; +using System.Configuration; using System.Reflection; using log4net.Util; @@ -36,6 +36,13 @@ /// This class is used by the wrapper managers (e.g. see cref=log4net.LogManager/) /// to provide access to the see cref=ILogger/ objects. /// /para + /// para + /// This manager also holds the see cref=IRepositorySelector/ that is used to + /// lookup and create repositories. The selector can be set either programmatically using + /// the see cref=RepositorySelector/ property, or by setting the clog4net.RepositorySelector/c + /// AppSetting in the applications config file to the fully qualified type name of the + /// selector to use. + /// /para /// /remarks /// authorNicko Cadell/author /// authorGert Driesen/author @@ -80,7 +87,7 @@ } catch(System.Security.SecurityException) { - LogLog.Debug(LoggerMAnager: Security Exception (ControlAppDomain LinkDemand) while trying + + LogLog.Debug(LoggerManager: Security Exception (ControlAppDomain LinkDemand) while trying + to register Shutdown handler with the AppDomain. LoggerManager.Shutdown() + will not be called automatically when the AppDomain exits. It must be called + programmatically.); @@ -93,7 +100,62 @@ #if NETCF s_repositorySelector = new CompactRepositorySelector(typeof(log4net.Repository.Hierarchy.Hierarchy)); #else - s_repositorySelector = new DefaultRepositorySelector(typeof(log4net.Repository.Hierarchy.Hierarchy)); + + // Look for the RepositorySelector type specified in the AppSettings 'log4net.RepositorySelector' + string appRepositorySelectorTypeName = null; + + try + { + appRepositorySelectorTypeName = ConfigurationSettings.AppSettings[log4net.RepositorySelector]; + } + catch(Exception ex) + { + // If an exception is thrown here then it looks like the config file does not parse correctly. + LogLog.Error(LoggerManager: Exception while reading ConfigurationSettings. Check your .config file is well formed XML., ex); + } + + if (appRepositorySelectorTypeName != null appRepositorySelectorTypeName.Length 0) + { + // Resolve the config string into a Type + Type appRepositorySelectorType = null; + try + { + appRepositorySelectorType = SystemInfo.GetTypeFromString(appRepositorySelectorTypeName, false, true); + } + catch(Exception ex) + { + LogLog.Error(LoggerManager: Exception while resolving RepositorySelector Type [+appRepositorySelectorTypeName+], ex); + } + + if (appRepositorySelectorType != null) + { + // Create an instance of the RepositorySelectorType + object appRepositorySelectorObj = null; + try + { + appRepositorySelectorObj = Activator.CreateInstance(appRepositorySelectorType); + } + catch(Exception ex) + { + LogLog.Error(LoggerManager: Exception while creating RepositorySelector
[jira] Resolved: (LOG4NET-37) Allow the RepositorySelector type to be sepecified using the AppSettings config
[ http://issues.apache.org/jira/browse/LOG4NET-37?page=all ] Nicko Cadell resolved LOG4NET-37: - Resolution: Fixed Added code to the LoggerManager to lookup the AppSettings key log4net.RepositorySelector for the type name of the selector to use. Allow the RepositorySelector type to be sepecified using the AppSettings config --- Key: LOG4NET-37 URL: http://issues.apache.org/jira/browse/LOG4NET-37 Project: Log4net Type: New Feature Components: Core Versions: 1.2.9 Reporter: Nicko Cadell Assignee: Nicko Cadell Priority: Minor Fix For: 1.2.10 Allow the RepositorySelector type to be sepecified using the AppSettings config. The RepositorySelector is set by default to be DefaultRepositorySelector. This can be changed programatically by setting the LoggerManager.RepositorySelector property, however it cannot be set at runtime via the application configuration files. Propose adding an AppSettings property 'log4net.RepositorySelector' that can be set to the type name of the repository selector to load. If this property is missing, or the type cannot be created the current default behaviour will continue. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
cvs commit: logging-log4net/tests/src/Appender RemotingAppenderTest.cs
nicko 2005/06/21 12:59:23 Modified:tests/src/Appender RemotingAppenderTest.cs Log: Tweaked test because of some timing issues Revision ChangesPath 1.4 +14 -7 logging-log4net/tests/src/Appender/RemotingAppenderTest.cs Index: RemotingAppenderTest.cs === RCS file: /home/cvs/logging-log4net/tests/src/Appender/RemotingAppenderTest.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- RemotingAppenderTest.cs 3 Apr 2005 18:01:05 - 1.3 +++ RemotingAppenderTest.cs 21 Jun 2005 19:59:23 - 1.4 @@ -18,14 +18,10 @@ using System; using System.Collections; -using System.Diagnostics; -using System.Globalization; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; -using log4net.Util; -using log4net.Layout; using log4net.Core; using log4net.Appender; using IRemoteLoggingSink = log4net.Appender.RemotingAppender.IRemoteLoggingSink; @@ -158,6 +154,8 @@ [Test] public void TestNestedNdc() { + // This test can suffer from timing and ordering issues as the RemotingAppender does dispatch events asynchronously + // Setup the remoting appender ConfigureRootAppender(FixFlags.Partial); @@ -168,7 +166,7 @@ t.Test(); // Wait for the remoted objects to be delivered - System.Threading.Thread.Sleep(2000); + System.Threading.Thread.Sleep(3000); LoggingEvent[] events = RemoteLoggingSinkImpl.Instance.Events; Assertion.AssertEquals(Expect to receive 5 remoted event, 5, events.Length); @@ -280,11 +278,13 @@ #region Implementation of IRemoteLoggingSink /// summary - /// Logs the events to the repository. + /// Logs the events to to an internal buffer /// /summary /// param name=eventsThe events to log./param /// remarks - /// The events passed are logged to the see cref=LoggerRepository/ + /// Logs the events to to an internal buffer. The logged events can + /// be retrieved via the see cref=Events/ property. To clear + /// the buffer call the see cref=Reset/ method. /// /remarks public void LogEvents(LoggingEvent[] events) { @@ -345,9 +345,12 @@ public void Test() { log.Info(begin test); + System.Threading.Thread.Sleep(100); + Feature f = new Feature(); f.Test(); log.Info(end test); + System.Threading.Thread.Sleep(100); } } } @@ -363,9 +366,12 @@ using(NDC.Push(test1)) { log.Info(feature); + System.Threading.Thread.Sleep(100); + log4net.Tests.Appender.Remoting.Data.Dal d = new log4net.Tests.Appender.Remoting.Data.Dal(); d.Test(); log.Info(return); + System.Threading.Thread.Sleep(100); } } } @@ -382,6 +388,7 @@ using(NDC.Push(test2)) { log.Info(return); + System.Threading.Thread.Sleep(100); } } }