zoukankan      html  css  js  c++  java
  • 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";
            }
  • 相关阅读:
    poj2240
    poj1135
    poj1062
    poj3278
    2218 补丁vs错误
    必做: 1041、1024、1077、2218、1183(较难)
    poj2828
    poj3253
    洛谷P1122 最大子树和
    1074 食物链
  • 原文地址:https://www.cnblogs.com/chucklu/p/13299783.html
Copyright © 2011-2022 走看看