logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1345560 - in /logging/log4net/trunk: src/Repository/Hierarchy/Hierarchy.cs tests/src/Hierarchy/Hierarchy.cs
Date Sat, 02 Jun 2012 19:16:35 GMT
Author: bodewig
Date: Sat Jun  2 19:16:35 2012
New Revision: 1345560

URL: http://svn.apache.org/viewvc?rev=1345560&view=rev
Log:
LOG4NET-343 exception if logger name is '.'

Modified:
    logging/log4net/trunk/src/Repository/Hierarchy/Hierarchy.cs
    logging/log4net/trunk/tests/src/Hierarchy/Hierarchy.cs

Modified: logging/log4net/trunk/src/Repository/Hierarchy/Hierarchy.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Repository/Hierarchy/Hierarchy.cs?rev=1345560&r1=1345559&r2=1345560&view=diff
==============================================================================
--- logging/log4net/trunk/src/Repository/Hierarchy/Hierarchy.cs (original)
+++ logging/log4net/trunk/src/Repository/Hierarchy/Hierarchy.cs Sat Jun  2 19:16:35 2012
@@ -866,7 +866,12 @@ namespace log4net.Repository.Hierarchy
 							LogLog.Error(declaringType, "Unexpected object type ["+node.GetType()+"] in ht.",
new LogException());
 						}
 					} 
-				} 
+				}
+				if (i == 0) {
+				    // logger name starts with a dot
+				    // and we've hit the start
+				    break;
+				}
 			}
 
 			// If we could not find any existing parents, then link with root.

Modified: logging/log4net/trunk/tests/src/Hierarchy/Hierarchy.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Hierarchy/Hierarchy.cs?rev=1345560&r1=1345559&r2=1345560&view=diff
==============================================================================
--- logging/log4net/trunk/tests/src/Hierarchy/Hierarchy.cs (original)
+++ logging/log4net/trunk/tests/src/Hierarchy/Hierarchy.cs Sat Jun  2 19:16:35 2012
@@ -48,9 +48,9 @@ namespace log4net.Tests.Hierarchy
                     <layout type=""log4net.Layout.SimpleLayout"" />
                   </appender>
                   <root>
-                    <level value=""ALL"" />                  
+                    <level value=""ALL"" />
                     <appender-ref ref=""StringAppender"" />
-                  </root>  
+                  </root>
                 </log4net>");
 
             ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
@@ -84,7 +84,7 @@ namespace log4net.Tests.Hierarchy
         {
             CountingAppender alpha = new CountingAppender();
             CountingAppender beta = new CountingAppender();
-            
+
             BasicConfigurator.Configure(alpha, beta);
 
             ILog log = LogManager.GetLogger(GetType());
@@ -93,5 +93,72 @@ namespace log4net.Tests.Hierarchy
             Assert.AreEqual(1, alpha.Counter);
             Assert.AreEqual(1, beta.Counter);
         }
+
+        [Test]
+	// LOG4NET-343
+        public void LoggerNameCanConsistOfASingleDot()
+        {
+            XmlDocument log4netConfig = new XmlDocument();
+            log4netConfig.LoadXml(@"
+                <log4net>
+                  <appender name=""StringAppender"" type=""log4net.Tests.Appender.StringAppender,
log4net.Tests"">
+                    <layout type=""log4net.Layout.SimpleLayout"" />
+                  </appender>
+                  <root>
+                    <level value=""ALL"" />
+                    <appender-ref ref=""StringAppender"" />
+                  </root>
+                  <logger name=""."">
+                    <level value=""WARN"" />
+                  </logger>
+                </log4net>");
+
+            ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
+            XmlConfigurator.Configure(rep, log4netConfig["log4net"]);
+        }
+
+        [Test]
+        public void LoggerNameCanConsistOfASingleNonDot()
+        {
+            XmlDocument log4netConfig = new XmlDocument();
+            log4netConfig.LoadXml(@"
+                <log4net>
+                  <appender name=""StringAppender"" type=""log4net.Tests.Appender.StringAppender,
log4net.Tests"">
+                    <layout type=""log4net.Layout.SimpleLayout"" />
+                  </appender>
+                  <root>
+                    <level value=""ALL"" />
+                    <appender-ref ref=""StringAppender"" />
+                  </root>
+                  <logger name=""L"">
+                    <level value=""WARN"" />
+                  </logger>
+                </log4net>");
+
+            ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
+            XmlConfigurator.Configure(rep, log4netConfig["log4net"]);
+        }
+
+        [Test]
+        public void LoggerNameCanContainSequenceOfDots()
+        {
+            XmlDocument log4netConfig = new XmlDocument();
+            log4netConfig.LoadXml(@"
+                <log4net>
+                  <appender name=""StringAppender"" type=""log4net.Tests.Appender.StringAppender,
log4net.Tests"">
+                    <layout type=""log4net.Layout.SimpleLayout"" />
+                  </appender>
+                  <root>
+                    <level value=""ALL"" />
+                    <appender-ref ref=""StringAppender"" />
+                  </root>
+                  <logger name=""L..M"">
+                    <level value=""WARN"" />
+                  </logger>
+                </log4net>");
+
+            ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
+            XmlConfigurator.Configure(rep, log4netConfig["log4net"]);
+        }
     }
 }



Mime
View raw message