nlog配置文件的自动查找
2023-09-11 14:14:18 时间
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"; }
相关文章
- Eclipse 自动补全代码返回值快捷键
- node开发自动刷新网页中的css和javascript
- 智能车竞赛自动裁判系统
- CES 2022:四大芯片巨头正面厮杀,抢滩自动驾驶、元宇宙
- CentOS7下搭建zabbix监控(五)——Web端配置自动发现并注册
- eclipse自动补全的设置(自动提示)
- DevEco Studio 无法使用自动补全如何解决 (HarmonyOS鸿蒙开发基础知识)
- vscode如何设置自动保存时自动格式化代码
- Windows下Qt打包:bat批处理脚本实现Qt自动打包
- Unity 之 UGUI Layout自动布局组件详解
- 真正实现一键自动化部署,Nginx+Tomcat+Redis 实现负载均衡集群服务搭建,所有文件自动生成,包括自动生成配置文件参数、解决依赖问题、Session共享同步、反向代理等等
- 【Unity笔记】UGUI的自动布局功能
- Java 基础 IDEA 自动清除没用的import
- zabbix 自动发现主机
- SpringBoot集成JPA根据实体类自动生成表