我的 asp .net C# MVC3 项目需要两个不同的日志文件。第一个应该记录所有异常级别(从警告到致命)。其他日志文件将用于记录某些信息,例如某些变量的值、某些计算的结果等。
我正在考虑将第二个日志文件配置为仅记录“信息”并使用 .info() 来存储所需的信息。这是正确的方法还是有更好的方法来做到这一点?我正在使用 Nlog 。
我的 asp .net C# MVC3 项目需要两个不同的日志文件。第一个应该记录所有异常级别(从警告到致命)。其他日志文件将用于记录某些信息,例如某些变量的值、某些计算的结果等。
我正在考虑将第二个日志文件配置为仅记录“信息”并使用 .info() 来存储所需的信息。这是正确的方法还是有更好的方法来做到这一点?我正在使用 Nlog 。
You should probably use Trace or Debug for your second log file instead of Info, I use Info for the successful process like "Process 1 OK : 10 files created", it's pretty usefull when you have many process to monitor. For what you describe, I think Debug will be perfect.
<targets>
<target name="errorLog" xsi:type="File"
fileName="error_${date:format=yyyyMMdd}.log"/>
<target name="traceLog" xsi:type="File"
fileName="trace_${date:format=yyyyMMdd}.log"/>
</targets>
<rules>
<logger name="*" writeTo="errorLog" minlevel="Warn"/>
<logger name="*" writeTo="traceLog" levels="Trace,Debug"/>
</rules>
For more infos NLog Wiki