/// <summary> /// Builds the default configuration item factory. /// </summary> /// <returns>Default factory.</returns> private static ConfigurationItemFactory BuildDefaultFactory() { var nlogAssembly = typeof(ILogger).Assembly; var factory = new ConfigurationItemFactory(nlogAssembly); factory.RegisterExtendedItems(); #if !SILVERLIGHT var assemblyLocation = Path.GetDirectoryName(new Uri(nlogAssembly.CodeBase).LocalPath); if (assemblyLocation == null) { InternalLogger.Warn("No auto loading because Nlog.dll location is unknown"); return(factory); } if (!Directory.Exists(assemblyLocation)) { InternalLogger.Warn("No auto loading because '{0}' doesn't exists", assemblyLocation); return(factory); } var extensionDlls = Directory.GetFiles(assemblyLocation, "NLog*.dll") .Select(Path.GetFileName) .Where(x => !x.Equals("NLog.dll", StringComparison.OrdinalIgnoreCase)) .Where(x => !x.Equals("NLog.UnitTests.dll", StringComparison.OrdinalIgnoreCase)) .Where(x => !x.Equals("NLog.Extended.dll", StringComparison.OrdinalIgnoreCase)) .Select(x => Path.Combine(assemblyLocation, x)); InternalLogger.Debug("Start auto loading, location: {0}", assemblyLocation); foreach (var extensionDll in extensionDlls) { InternalLogger.Info("Auto loading assembly file: {0}", extensionDll); var success = false; try { var extensionAssembly = Assembly.LoadFrom(extensionDll); InternalLogger.LogAssemblyVersion(extensionAssembly); factory.RegisterItemsFromAssembly(extensionAssembly); success = true; } catch (Exception ex) { if (ex.MustBeRethrownImmediately()) { throw; } InternalLogger.Warn(ex, "Auto loading assembly file: {0} failed! Skipping this file.", extensionDll); //TODO NLog 5, check MustBeRethrown() } if (success) { InternalLogger.Info("Auto loading assembly file: {0} succeeded!", extensionDll); } } InternalLogger.Debug("Auto loading done"); #endif return(factory); }
private void LogConfigurationInitialized() { InternalLogger.Info("Configuration initialized."); InternalLogger.LogAssemblyVersion(typeof(ILogger).Assembly); }