一个解决方案,不同项目的NLog只输出到一个文件嘛?
想请教一下:我一个解决方案中有多个项目,每个项目中配了各自的NLog.config文件,每个项目的log输出到不同的文件;发现两个问题:
1.debug的时候,输出的是我启动项目配置的log文件名,但其他项目的log也输出到这里,跟我想的,输出到不同的文件不匹配;
2.程序发布后运行时,发现保存的log是另外一个项目配置的log输出,跟debug时输出的log文件名不同;同样,所有的log也只是输出到这个文件中;
下面是我的配置文件内容;能否帮忙解答一下上面的问题?谢谢
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<variable name="logDirectory" value="${basedir}/../Logs/ConfigUpdate/ConfigUpdate.log"/>
<targets>
<target
name="logfile"
xsi:type="File"
fileName="${var:logDirectory}"
maxArchiveFiles="5"
archiveAboveSize="10240"
archiveFileName="${basedir}/../Logs/archives_ConfigUpdate/ConfigUpdate.{#####}.log"
archiveNumbering="Sequence"
concurrentWrites="true"
keepFileOpen="false"
layout="${longdate} ${level} ${message} ${callsite:className=false:fileName=True:includeSourcePath=false:methodName=false}${newline}"/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="logfile" />
</rules>
</nlog>
1.debug的时候,输出的是我启动项目配置的log文件名,但其他项目的log也输出到这里,跟我想的,输出到不同的文件不匹配;
2.程序发布后运行时,发现保存的log是另外一个项目配置的log输出,跟debug时输出的log文件名不同;同样,所有的log也只是输出到这个文件中;
下面是我的配置文件内容;能否帮忙解答一下上面的问题?谢谢
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<variable name="logDirectory" value="${basedir}/../Logs/ConfigUpdate/ConfigUpdate.log"/>
<targets>
<target
name="logfile"
xsi:type="File"
fileName="${var:logDirectory}"
maxArchiveFiles="5"
archiveAboveSize="10240"
archiveFileName="${basedir}/../Logs/archives_ConfigUpdate/ConfigUpdate.{#####}.log"
archiveNumbering="Sequence"
concurrentWrites="true"
keepFileOpen="false"
layout="${longdate} ${level} ${message} ${callsite:className=false:fileName=True:includeSourcePath=false:methodName=false}${newline}"/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="logfile" />
</rules>
</nlog>
...全文
相关推荐
.Net项目中NLog的配置和使用实例详解
主要给大家介绍了关于.Net项目中NLog的配置和使用的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用.Net具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
asp.net core 使用NLog打印日志到txt文件
asp.net core 使用NLog打印日志到txt文件。 每个txt文件支持设置最大值,如设置为1M,则每个日志超过1M,会生成新的日志文件; 日志支持显示所在位置以及行号;
NLog 一个Opensource的日志系统;
一个功能强大,设计简洁的日志系统,C#版本,全部源程序,非常适合在项目中使用;
nlog/log4net配置文件
给伸手党。已经测试。 说明nlog:输出bin/debug/logs log4net输出bin/debug/logs
NLog Dome 实例
一个Nlog的 使用实例,包括输出到文件、Debugger、控制台、数据库,邮件、ElasticSearch ,


