• nlog配置文件的自动查找


    https://github.com/NLog/NLog/blob/dev/src/NLog/Config/LoggingConfigurationFileLoader.cs#L222

     /// <summary>
            /// Get default file paths (including filename) for possible NLog config files. 
            /// </summary>
            public IEnumerable<string> GetDefaultCandidateConfigFilePaths(string filename = null)
            {
                if (filename == null)
                {
                    // Scan for process specific nlog-files
                    foreach (var filePath in GetAppSpecificNLogLocations())
                        yield return filePath;
                }
    
                // NLog.config from application directory
                string nlogConfigFile = filename ?? "NLog.config";
                string baseDirectory = PathHelpers.TrimDirectorySeparators(_appEnvironment.AppDomainBaseDirectory);
                if (!string.IsNullOrEmpty(baseDirectory))
                    yield return Path.Combine(baseDirectory, nlogConfigFile);
    
                string nLogConfigFileLowerCase = nlogConfigFile.ToLower();
                bool platformFileSystemCaseInsensitive = nlogConfigFile == nLogConfigFileLowerCase || PlatformDetector.IsWin32;
                if (!platformFileSystemCaseInsensitive && !string.IsNullOrEmpty(baseDirectory))
                    yield return Path.Combine(baseDirectory, nLogConfigFileLowerCase);
    
    #if !NETSTANDARD1_3
                string entryAssemblyLocation = PathHelpers.TrimDirectorySeparators(_appEnvironment.EntryAssemblyLocation);
    #else
                string entryAssemblyLocation = string.Empty;
    #endif
                if (!string.IsNullOrEmpty(entryAssemblyLocation) && !string.Equals(entryAssemblyLocation, baseDirectory, StringComparison.OrdinalIgnoreCase))
                {
                    yield return Path.Combine(entryAssemblyLocation, nlogConfigFile);
                    if (!platformFileSystemCaseInsensitive)
                        yield return Path.Combine(entryAssemblyLocation, nLogConfigFileLowerCase);
                }
    
                if (string.IsNullOrEmpty(baseDirectory))
                {
                    yield return nlogConfigFile;
                    if (!platformFileSystemCaseInsensitive)
                        yield return nLogConfigFileLowerCase;
                }
    
                foreach (var filePath in GetPrivateBinPathNLogLocations(baseDirectory, nlogConfigFile, platformFileSystemCaseInsensitive ? nLogConfigFileLowerCase : string.Empty))
                    yield return filePath;
    
                string nlogAssemblyLocation = filename != null ? null : LookupNLogAssemblyLocation();
                if (nlogAssemblyLocation != null)
                    yield return nlogAssemblyLocation + ".nlog";
            }
  • 相关阅读:
    数学之美:判断两个随机信号序列相似度
    为什么自己设计的嵌入式系统不如工业级产品稳定?
    由static来谈谈模块封装
    算法类书籍汇总
    Linux驱动:手把手教hello world驱动配置、编译进内核或为模块
    刨根问底之链表数据结构
    Redis进阶
    构建高可用的写服务
    再推荐 5 款私藏的优质 Chrome 插件
    MySQL-SQL优化
  • 原文地址:https://www.cnblogs.com/chucklu/p/13299783.html
Copyright © 2020-2023  润新知