在PowerShell中使用Nlog-Logger时禁用了残疾人
我的nlog.config
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xsi:schemaLocation="NLog NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogFile="c:\temp\console-example-internal.log"
internalLogLevel="Info" >
<!-- the targets to write to -->
<targets>
<target xsi:type="File" name="logfile" fileName="c:\temp\console-example.log"
layout="${shortdate} | ${level} | ${callsite} | ${message} | ${all-event-properties} ${exception:format=tostring}" />
<target xsi:type="Console" name="logconsole"
layout="${shortdate} | ${level} | ${callsite} | ${message} | ${all-event-properties} ${exception:format=tostring}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<logger name="*" minlevel="Trace" writeTo="logfile,logconsole" />
</rules>
</nlog>
当我在powerShell中导入nlog.dll时,从logmanager.getCurrentCrastLogger()禁用了logmanager.getCurrentClassLogger()。因此我无法记录。
My nlog.config
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xsi:schemaLocation="NLog NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogFile="c:\temp\console-example-internal.log"
internalLogLevel="Info" >
<!-- the targets to write to -->
<targets>
<target xsi:type="File" name="logfile" fileName="c:\temp\console-example.log"
layout="${shortdate} | ${level} | ${callsite} | ${message} | ${all-event-properties} ${exception:format=tostring}" />
<target xsi:type="Console" name="logconsole"
layout="${shortdate} | ${level} | ${callsite} | ${message} | ${all-event-properties} ${exception:format=tostring}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<logger name="*" minlevel="Trace" writeTo="logfile,logconsole" />
</rules>
</nlog>
When i import the Nlog.dll in PowerShell the logger from LogManager.GetCurrentClassLogger() is disabled. Therefore i can't log.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在PowerShell中,必须手动设置nlog.config。
https://github.github.github.com/rafpe/rrafpe/953838c51Edb7fb7efb7efb7efb7efb7efb7f43c4
In PowerShell one has to set the nlog.config manually.
https://gist.github.com/RafPe/95ef838c51edb7ef43c4