Error Log

From AbleCommerce Wiki

Jump to: navigation, search

From the help menu in merchant administration, you can access the error log. This screen shows all pertinent warnings and errors registered by the AbleCommerce software. If entries appear here, you will receive a notification on the merchant dashboard. You should review errors here and determine whether any action is required.

Advanced Error Logging

Behind the scenes AbleCommerce uses [log4net] for the logging facility. This is a robust and flexible logging platform that can be reconfigured to fit your needs. A frequent example is the desire to have error notifications sent via email. This is easy to accomplish with a modification to the log4net configuration file. By default, AbleCommerce stores this file in App_Data/log4net.config. The code below is an example of a config file that logs the errors to file as well as email using the SMTP appender:

<log4net>
  <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="App_Data\\Logs\\app.log" />
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="10MB" />
    <staticLogFileName value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n" />
    </layout>
  </appender>
  <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
    <to value="to@domain" />
    <from value="from@domain" />
    <subject value="Subject of error message" />
    <smtpHost value="smtp.server.address" />
    <bufferSize value="10" />
    <lossy value="true" />
    <evaluator type="log4net.Core.LevelEvaluator">
        <threshold value="WARN"/>
    </evaluator>
    <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" />
    </layout>
  </appender>
  <root>
    <level value="All" />
    <appender-ref ref="RollingLogFileAppender" />
    <appender-ref ref="SmtpAppender" />
  </root>
</log4net>

Logging is not limited to file or email. You could also register logs to another database, the windows event log, and more. A good starting point are the examples provided by Apache.

Personal tools