locked
Nlog IsError false and isInfo RRS feed

  • Question

  • I have NLog.config looks like


    <?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="${specialfolder:folder=ApplicationData}/ErrorLog"/>
      <variable name="archiveDirectory" value="${specialfolder:folder=ApplicationData}/ErrorLog/archives/${shortdate}"/>
      <variable name="defaultFileName" value ="normal_log_"/>
      <variable name="defaultErrorFileName" value ="errors-log_"/>
    
      <targets async="true">
        <target name="console" xsi:type="Console" layout="${longdate} | ${level} | ${callsite} | ${message}" />
        <target name="default" xsi:type="File" layout="${longdate} | ${level} | ${callsite} | ${message}" fileName="${logDirectory}/${defaultFileName}{#}.txt" archiveFileName="${archiveDirectory}/${defaultFileName}{#}.txt" archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="7" />
        <target name="errors" xsi:type="File" layout="${longdate} | ${level} | ${callsite} | ${message}" fileName="${logDirectory}/${defaultErrorFileName}{#}.txt" archiveFileName="${archiveDirectory}/${defaultErrorFileName}{#}.txt" archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="7" />
      </targets>
    
      <rules>
        <logger name="*" writeTo="default" />
        <logger name="*" writeTo="console" minlevel="Info" />
        <logger name="*" writeTo="errors" minlevel="Error" />
      </rules>
    
    
    
    </nlog>

    and I use it like

    public static class Log
    {
        private static Logger logger;
    
        static Log()
        {
             logger = LogManager.GetCurrentClassLogger();              
        }
    
        public static void LogError(Exception ex)
        {
            logger.Error<Exception>(ex);
        }
    

    but nothing is written to App_Data\errorlog . after debugging I noticed that all of its properties is false

    any idea how to fix that



    • Moved by Caillen Sunday, June 8, 2014 2:27 PM
    Tuesday, May 27, 2014 11:20 PM

Answers

  • Ask here: https://groups.google.com/forum/#!forum/nlog-users


    Visual C++ MVP

    • Proposed as answer by Caillen Thursday, May 29, 2014 9:58 AM
    • Marked as answer by Just Karl Sunday, June 8, 2014 4:05 PM
    Tuesday, May 27, 2014 11:34 PM