private static IEnumerable <string> GetCandidateFileNames() { #if NET_CF yield return(CompactFrameworkHelper.GetExeFileName() + ".nlog"); yield return(Path.Combine(Path.GetDirectoryName(CompactFrameworkHelper.GetExeFileName()), "NLog.config")); yield return(typeof(LogFactory).Assembly.GetName().CodeBase + ".nlog"); #elif SILVERLIGHT yield return("NLog.config"); #else // NLog.config from application directory yield return(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NLog.config")); // current config file with .config renamed to .nlog var cf = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; if (cf != null) { yield return(Path.ChangeExtension(cf, ".nlog")); } // get path to NLog.dll.nlog only if the assembly is not in the GAC var nlogAssembly = typeof(LogFactory).Assembly; if (!nlogAssembly.GlobalAssemblyCache) { if (!string.IsNullOrEmpty(nlogAssembly.Location)) { yield return(nlogAssembly.Location + ".nlog"); } } #endif }
/// <summary> /// Creates a new instance of <see cref="BaseDirLayoutRenderer"/>. /// </summary> public BaseDirLayoutRenderer() { #if !NETCF _baseDir = AppDomain.CurrentDomain.BaseDirectory; #else _baseDir = CompactFrameworkHelper.GetExeBaseDir(); #endif }
protected XmlLoggingConfiguration CreateConfigurationFromString(string configXml) { #if SILVERLIGHT XElement element = XElement.Parse(configXml); return(new XmlLoggingConfiguration(element.CreateReader(), null)); #else XmlDocument doc = new XmlDocument(); doc.LoadXml(configXml); #if NET_CF Console.WriteLine(CompactFrameworkHelper.GetExeBaseDir()); return(new XmlLoggingConfiguration(doc.DocumentElement, ".")); #else return(new XmlLoggingConfiguration(doc.DocumentElement, Environment.CurrentDirectory)); #endif #endif }
private static IEnumerable <string> GetCandidateFileNames() { #if NET_CF yield return(CompactFrameworkHelper.GetExeFileName() + ".nlog"); yield return(Path.Combine(Path.GetDirectoryName(CompactFrameworkHelper.GetExeFileName()), "NLog.config")); yield return(typeof(LogFactory).Assembly.GetName().CodeBase + ".nlog"); #elif SILVERLIGHT yield return("NLog.config"); #else // NLog.config from application directory yield return(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NLog.config")); // current config file with .config renamed to .nlog string cf = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; if (cf != null) { yield return(Path.ChangeExtension(cf, ".nlog")); } #endif }