标签:修改环境变量 配置 color write intern microsoft targe -- getenv
<?xml version="1.0"?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" internalLogLevel="Warn" internalLogFile="${basedir}\logs\internal-nlog.txt"> <extensions> <add assembly="NLog.Web.AspNetCore"/> </extensions> <targets> <target name="allfile" xsi:type="File" fileName="${basedir}\logs\GDStationaryNetCore\${shortdate}.log" encoding="utf-8" layout="[${longdate}][${machinename}][${level}] ${message} ${exception}" /> </targets> <rules> <!--All logs, including from Microsoft--> <logger name="*" minlevel="Trace" writeTo="allfile" /> <!--Skip Microsoft logs and so log only own logs--> <logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" /> <logger name="*" minlevel="Trace" writeTo="ownFile-web" /> </rules> </nlog>
另一份配置文件与上面一样,修改保存日志的目录为其他目录
//根据环境变量切换NLog配置 var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); var isProd = environment == EnvironmentName.Production; env.ConfigureNLog(isProd ? "nlog.config" : "nlog.debug.config");
可在工程的属性 调试里修改环境变量
标签:修改环境变量 配置 color write intern microsoft targe -- getenv
原文地址:https://www.cnblogs.com/zhouxiaoyun/p/10770866.html