using System;
using System.Reflection;
using log4net;
namespace Extensions
{
public static class LogExtensions
{
public static void RecursiveLogError(this ILog logger, Exception exception)
{
if (logger == null) throw new ArgumentNullException("logger");
if (exception == null) throw new ArgumentNullException("exception");
logger.Error(exception.Message + "\n" + exception.StackTrace, exception);
if (exception.InnerException != null)
{
RecursiveLogError(logger, exception.InnerException);
}
var typeLoadException = exception as ReflectionTypeLoadException;
if (typeLoadException == null) return;
foreach (var loaderException in typeLoadException.LoaderExceptions)
RecursiveLogError(logger, loaderException);
}
}
}