示例#1
0
        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
        }
示例#2
0
        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
        }