Reputation: 999
I need two different log files for my asp .net C# MVC3 project . First one should log all exception levels (from warn to fatal). Other log file will be used to log certain information like values of certain variables , results of some computation etc .
I was thinking of configuring second log file to log only 'Info' and use .info() to store required info . Is this right approach or is there any better way to do this? I'm using Nlog .
Upvotes: 3
Views: 3090
Reputation: 61
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
Upvotes: 4