NH-2821 - another approach to finding log4net #73

Closed
wants to merge 1 commit into
from
View
10 src/NHibernate/Logging.cs
@@ -58,15 +58,15 @@ private static ILoggerFactory GetLoggerFactory(string nhibernateLoggerClass)
var loggerFactoryType = System.Type.GetType(nhibernateLoggerClass);
try
{
- loggerFactory = (ILoggerFactory) Activator.CreateInstance(loggerFactoryType);
+ loggerFactory = (ILoggerFactory)Activator.CreateInstance(loggerFactoryType);
}
catch (MissingMethodException ex)
{
throw new ApplicationException("Public constructor was not found for " + loggerFactoryType, ex);
}
catch (InvalidCastException ex)
{
- throw new ApplicationException(loggerFactoryType + "Type does not implement " + typeof (ILoggerFactory), ex);
+ throw new ApplicationException(loggerFactoryType + "Type does not implement " + typeof(ILoggerFactory), ex);
}
catch (Exception ex)
{
@@ -87,9 +87,9 @@ private static string GetNhibernateLoggerClass()
string binPath = relativeSearchPath == null ? baseDir : Path.Combine(baseDir, relativeSearchPath);
string log4NetDllPath = binPath == null ? "log4net.dll" : Path.Combine(binPath, "log4net.dll");
- if (File.Exists(log4NetDllPath))
+ if (File.Exists(log4NetDllPath) || AppDomain.CurrentDomain.GetAssemblies().Any(a => a.GetName().Name == "log4net"))
{
- nhibernateLoggerClass = typeof (Log4NetLoggerFactory).AssemblyQualifiedName;
+ nhibernateLoggerClass = typeof(Log4NetLoggerFactory).AssemblyQualifiedName;
}
}
else
@@ -138,7 +138,7 @@ public class NoLoggingInternalLogger: IInternalLogger
{
public bool IsErrorEnabled
{
- get { return false;}
+ get { return false; }
}
public bool IsFatalEnabled