diff --git a/src/NHibernate.Test/App.config b/src/NHibernate.Test/App.config
index d3965012af5..40cf748a495 100644
--- a/src/NHibernate.Test/App.config
+++ b/src/NHibernate.Test/App.config
@@ -3,7 +3,6 @@
-
@@ -52,50 +51,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/src/NHibernate.Test/Hql/Ast/ParsingFixture.cs b/src/NHibernate.Test/Hql/Ast/ParsingFixture.cs
index 040ba037b9a..45be4789f1c 100644
--- a/src/NHibernate.Test/Hql/Ast/ParsingFixture.cs
+++ b/src/NHibernate.Test/Hql/Ast/ParsingFixture.cs
@@ -74,8 +74,6 @@ namespace NHibernate.Test.Hql.Ast
// [Test]
// public void BasicQuery()
// {
- // XmlConfigurator.Configure();
-
// string input = "select o.id, li.id from NHibernate.Test.CompositeId.Order o join o.LineItems li";// join o.LineItems li";
// ISessionFactoryImplementor sfi = SetupSFI();
@@ -175,4 +173,4 @@ namespace NHibernate.Test.Hql.Ast
// }
// }
//}
-}
\ No newline at end of file
+}
diff --git a/src/NHibernate.Test/Log4netConfiguration.cs b/src/NHibernate.Test/Log4netConfiguration.cs
deleted file mode 100644
index 841ecc09911..00000000000
--- a/src/NHibernate.Test/Log4netConfiguration.cs
+++ /dev/null
@@ -1,2 +0,0 @@
-using log4net.Config;
-[assembly: XmlConfigurator()]
\ No newline at end of file
diff --git a/src/NHibernate.Test/NHSpecificTest/NH1587/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1587/Fixture.cs
index 6a716ce5a66..68eb38d6bab 100644
--- a/src/NHibernate.Test/NHSpecificTest/NH1587/Fixture.cs
+++ b/src/NHibernate.Test/NHSpecificTest/NH1587/Fixture.cs
@@ -1,5 +1,3 @@
-using log4net;
-using log4net.Config;
using log4net.Core;
using NHibernate.Cfg;
using NUnit.Framework;
@@ -12,7 +10,6 @@ public class Fixture
[Test]
public void Bug()
{
- XmlConfigurator.Configure(LogManager.GetRepository(typeof(Fixture).Assembly));
var cfg = new Configuration();
if (TestConfigurationHelper.hibernateConfigFile != null)
cfg.Configure(TestConfigurationHelper.hibernateConfigFile);
diff --git a/src/NHibernate.Test/NHibernate.Test.csproj b/src/NHibernate.Test/NHibernate.Test.csproj
index 16ef3aab72e..11e964f39a6 100644
--- a/src/NHibernate.Test/NHibernate.Test.csproj
+++ b/src/NHibernate.Test/NHibernate.Test.csproj
@@ -25,6 +25,7 @@
+
Always
diff --git a/src/NHibernate.Test/TestCase.cs b/src/NHibernate.Test/TestCase.cs
index 600265ade3f..14fc4ad1460 100644
--- a/src/NHibernate.Test/TestCase.cs
+++ b/src/NHibernate.Test/TestCase.cs
@@ -4,7 +4,6 @@
using System.Data;
using System.Reflection;
using log4net;
-using log4net.Config;
using NHibernate.Cfg;
using NHibernate.Connection;
using NHibernate.Engine;
@@ -56,12 +55,6 @@ protected virtual string MappingsAssembly
protected SchemaExport SchemaExport => _schemaExport ?? (_schemaExport = new SchemaExport(cfg));
- static TestCase()
- {
- // Configure log4net here since configuration through an attribute doesn't always work.
- XmlConfigurator.Configure(LogManager.GetRepository(typeof(TestCase).Assembly));
- }
-
///
/// Creates the tables used in this TestCase
///
diff --git a/src/NHibernate.Test/TestsContext.cs b/src/NHibernate.Test/TestsContext.cs
index 4eae9d561e5..e80cca726aa 100644
--- a/src/NHibernate.Test/TestsContext.cs
+++ b/src/NHibernate.Test/TestsContext.cs
@@ -1,9 +1,8 @@
-#if NETCOREAPP2_0
-using NUnit.Framework;
-
+using NUnit.Framework;
using System.Configuration;
-using System.IO;
-using log4net.Repository.Hierarchy;
+using System.Reflection;
+using log4net;
+using log4net.Config;
using NHibernate.Cfg;
namespace NHibernate.Test
@@ -11,40 +10,25 @@ namespace NHibernate.Test
[SetUpFixture]
public class TestsContext
{
- private static bool ExecutingWithVsTest { get; } =
- System.Reflection.Assembly.GetEntryAssembly()?.GetName().Name == "testhost";
+ private static readonly Assembly TestAssembly = typeof(TestsContext).Assembly;
[OneTimeSetUp]
public void RunBeforeAnyTests()
{
+ ConfigureLog4Net();
+
//When .NET Core App 2.0 tests run from VS/VSTest the entry assembly is "testhost.dll"
//so we need to explicitly load the configuration
- if (ExecutingWithVsTest)
+ if (Assembly.GetEntryAssembly() != null)
{
- var assemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, Path.GetFileName(typeof(TestsContext).Assembly.Location));
- ConfigurationProvider.Current = new SystemConfigurationProvider(ConfigurationManager.OpenExeConfiguration(assemblyPath));
+ ConfigurationProvider.Current = new SystemConfigurationProvider(ConfigurationManager.OpenExeConfiguration(TestAssembly.Location));
}
-
- ConfigureLog4Net();
}
private static void ConfigureLog4Net()
{
- var hierarchy = (Hierarchy)log4net.LogManager.GetRepository(typeof(TestsContext).Assembly);
-
- var consoleAppender = new log4net.Appender.ConsoleAppender
- {
- Layout = new log4net.Layout.PatternLayout("%d{ABSOLUTE} %-5p %c{1}:%L - %m%n"),
- };
-
- ((Logger)hierarchy.GetLogger("NHibernate.Hql.Ast.ANTLR")).Level = log4net.Core.Level.Off;
- ((Logger)hierarchy.GetLogger("NHibernate.SQL")).Level = log4net.Core.Level.Off;
- ((Logger)hierarchy.GetLogger("NHibernate.AdoNet.AbstractBatcher")).Level = log4net.Core.Level.Off;
- ((Logger)hierarchy.GetLogger("NHibernate.Tool.hbm2ddl.SchemaExport")).Level = log4net.Core.Level.Error;
- hierarchy.Root.Level = log4net.Core.Level.Warn;
- hierarchy.Root.AddAppender(consoleAppender);
- hierarchy.Configured = true;
+ using (var log4NetXml = TestAssembly.GetManifestResourceStream("NHibernate.Test.log4net.xml"))
+ XmlConfigurator.Configure(LogManager.GetRepository(TestAssembly), log4NetXml);
}
}
}
-#endif
diff --git a/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs b/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs
index 33bfe99a710..3efb4bbf5b5 100644
--- a/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs
+++ b/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs
@@ -1,6 +1,5 @@
using System;
using log4net;
-using log4net.Repository.Hierarchy;
using NHibernate.Type;
using NUnit.Framework;
@@ -12,11 +11,6 @@ namespace NHibernate.Test.TypesTest
[TestFixture]
public class TypeFactoryFixture
{
- public TypeFactoryFixture()
- {
- log4net.Config.XmlConfigurator.Configure(LogManager.GetRepository(typeof(TypeFactoryFixture).Assembly));
- }
-
private static readonly ILog log = LogManager.GetLogger(typeof(TypeFactoryFixture));
///
diff --git a/src/NHibernate.Test/log4net.xml b/src/NHibernate.Test/log4net.xml
new file mode 100644
index 00000000000..01844a5d696
--- /dev/null
+++ b/src/NHibernate.Test/log4net.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+