E-mail notification when errors occur

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
NC Software
AbleCommerce Partner
AbleCommerce Partner
Posts: 4620
Joined: Mon Sep 13, 2004 6:06 pm
Contact:

E-mail notification when errors occur

Post by NC Software » Fri Jul 17, 2009 6:43 am

It would have really helped me, the System Admin (whatever the role is called) to get an e-mail notification of error log entries. If I had been getting notified by e-mail, SMS, whatever, that an error occurred, I would have been on top of the e-mail template system as it generated errors when trying to parse the nVelocity stuff that got pooched by the FCK'ing editor. I suggest add an option to e-mail the admin (or enter an address for error notifications). I just now noticed there were errors in the error log and they indicated the e-mail templates were pooched but I wasn't aware of the errors.
Neal Culiner
NC Software, Inc.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: E-mail notification when errors occur

Post by mazhar » Wed Jul 22, 2009 9:51 am

Read following thread
viewtopic.php?f=42&t=11796

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: E-mail notification when errors occur

Post by AbleMods » Wed Jul 22, 2009 10:35 am

That NEEDS to go into 7.0.5
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
calvis
Rear Admiral (RADM)
Rear Admiral (RADM)
Posts: 710
Joined: Tue Jan 27, 2004 3:57 pm
Location: Redmond, WA

Re: E-mail notification when errors occur

Post by calvis » Wed Jul 22, 2009 11:11 am

Thanks Mazhar,

I have added that to my code snippet library.
Able Customer Since 1999 Currently Running on GOLD R12 SR1 and PCI Certified.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: E-mail notification when errors occur

Post by jmestep » Wed Jul 22, 2009 2:36 pm

Yes, that is great. I've had code in a global.asax file and code that runs with Elmah.dll stuff, but neither of them works well consistently.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: E-mail notification when errors occur

Post by Logan Rhodehamel » Wed Jul 22, 2009 4:18 pm

Another way to approach this would be to alter the log4net.config file. I should construct a tutorial on that.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: E-mail notification when errors occur

Post by Logan Rhodehamel » Fri Jul 24, 2009 10:28 am

As I mentioned in my previous post, we use log4net as our logging facility. This is a fairly common logging system that is used by a wide variety of applications. It is also highly configurable.

All of the settings for log4net reside in App_Data\log4net.config. NOTE: Any change to log4net.config will require a manual restart of the application to take effect. The quick hack way of doing this is to open the web.config in the root of your website, go to the end of the file, press enter, and save. The file change will trigger an automatic restart of the app and reload the log4net.config file.

The log4net library supports a huge range of "appenders"... It is the appender that decides whether to log your error to file, to database, to the console, to the windows event log, to email, etc. You can configure multiple appenders.

One benefit to doing this for the email vs a global.asax change is that you can also get context information... log4net will send you X number of messages prior to the exception. It may or may not be helpful. I am going to post a sample log4net.config file that has been modified to send email:

Code: Select all

<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>
In the SmtpAppender definition, buffer size indicates how many of the prior log messages will be included. Threshold indicates what level will register the email. I have it set to WARN. You could also set it to ERROR to only see more critical problems.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: E-mail notification when errors occur

Post by Logan Rhodehamel » Fri Jul 24, 2009 10:30 am

I have moved this thread to the main forum as others may be interested to see how to make this configuration change.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

Post Reply