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";
            }
  • 相关阅读:
    Javascript中怎么定义类(私有成员、静态成员)?
    Web前端国内的叫法与行业归类吗
    CSS hack,CSS简写,CSS定义应注意的几个问题
    7个在IE和Firefox中不同的JavaScript语法
    IE和Firefox中的事件
    IE8的css hack /9
    CSS hack
    运行,复制,保存,runCode,copyCode,saveCode,运行代码框
    自由使用层的叠加
    WordPress自定义URL的Rewrite规则
  • 原文地址:https://www.cnblogs.com/chucklu/p/13299783.html
Copyright © 2011-2022 走看看