fixed path.combine null exception if the config doesnt exist

This commit is contained in:
chris.watts90@outlook.com 2017-02-16 22:16:37 +00:00
parent ebfced87ee
commit 1babd514ce

View File

@ -13,11 +13,12 @@ namespace NLogLogger
private NLog.Logger _logger; private NLog.Logger _logger;
public NLogger() public NLogger()
{ {
var nlogConfigPath = new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), ConfigurationManager.AppSettings["NLogConfigFilePath"])).LocalPath; var nlogConfigPathOption = ConfigurationManager.AppSettings["NLogConfigFilePath"];
if (nlogConfigPath == null) if (nlogConfigPathOption == null)
{ {
throw new ArgumentNullException("nlogConfigPath"); throw new ArgumentNullException("nlogConfigPath");
} }
var nlogConfigPath = new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), nlogConfigPathOption)).LocalPath;
LogManager.Configuration = new XmlLoggingConfiguration(nlogConfigPath); LogManager.Configuration = new XmlLoggingConfiguration(nlogConfigPath);
_logger = LogManager.GetLogger(""); _logger = LogManager.GetLogger("");
} }