Skip to content

Commit 2fee701

Browse files
committed
Avoid log4net multiple configure calls
1 parent d1eb90f commit 2fee701

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/NHibernate.Test/Hql/Ast/ParsingFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace NHibernate.Test.Hql.Ast
7474
// [Test]
7575
// public void BasicQuery()
7676
// {
77-
// XmlConfigurator.Configure();
77+
// TestCase.ForceLogConfiguration();
7878

7979
// string input = "select o.id, li.id from NHibernate.Test.CompositeId.Order o join o.LineItems li";// join o.LineItems li";
8080

@@ -175,4 +175,4 @@ namespace NHibernate.Test.Hql.Ast
175175
// }
176176
// }
177177
//}
178-
}
178+
}

src/NHibernate.Test/NHSpecificTest/NH1587/Fixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class Fixture
1212
[Test]
1313
public void Bug()
1414
{
15-
XmlConfigurator.Configure(LogManager.GetRepository(typeof(Fixture).Assembly));
15+
TestCase.ForceLogConfiguration();
1616
var cfg = new Configuration();
1717
if (TestConfigurationHelper.hibernateConfigFile != null)
1818
cfg.Configure(TestConfigurationHelper.hibernateConfigFile);

src/NHibernate.Test/TestCase.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,13 @@ protected virtual string MappingsAssembly
5555

5656
static TestCase()
5757
{
58-
// Configure log4net here since configuration through an attribute doesn't always work.
59-
XmlConfigurator.Configure(LogManager.GetRepository(typeof(TestCase).Assembly));
58+
ForceLogConfiguration();
59+
}
60+
61+
public static void ForceLogConfiguration()
62+
{
63+
//Makes sure that logger is initialized from assembly configuration attribute (see Log4NetConfigurator)
64+
LogManager.GetRepository(typeof(TestCase).Assembly);
6065
}
6166

6267
/// <summary>

src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using log4net;
3-
using log4net.Repository.Hierarchy;
43
using NHibernate.Type;
54
using NUnit.Framework;
65

@@ -14,7 +13,7 @@ public class TypeFactoryFixture
1413
{
1514
public TypeFactoryFixture()
1615
{
17-
log4net.Config.XmlConfigurator.Configure(LogManager.GetRepository(typeof(TypeFactoryFixture).Assembly));
16+
TestCase.ForceLogConfiguration();
1817
}
1918

2019
private static readonly ILog log = LogManager.GetLogger(typeof(TypeFactoryFixture));

0 commit comments

Comments
 (0)