Application Error Emails

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
7/27/2011 8:52:50 AM
Gravatar
Total Posts 130

Application Error Emails

Hi Joe,

Is there any logic in place to email an administer with application error logs in mojoPortal?  Anything I can add to the web.config to get notified of errors?

Thanks,

Beth

7/27/2011 9:54:36 AM
Gravatar
Total Posts 18439

Re: Application Error Emails

Hi Beth,

Yes it is possible, log4net supports an smtp appended that can be used to email logged events. If you look in the log4net.config file in the root of the web you'll see information in comments about how it can be configured. Note that if you customize the log4net.config file you should keep a copy of it as log4net.backup.config so you can restore your customizations easily after upgrades.

However, that said, it will probably be very annoying receiving that many emails. I know my log is very noisy with things poking at the site and mangling url fragments together resulting in lots of page not found errors. I find it easier to just review my logs several times a day and I clear the log after each time I review it.

I'm actually working on support for logging to the database as part of my effort for web farm support.

Hope that helps,

Joe

7/27/2011 10:02:57 AM
Gravatar
Total Posts 1196
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Application Error Emails

Hey Joe, I saw that you were working on DB logging in the source downloads. If you implement optional emailing of errors to go along with your logging, it would be really cool to be able to exclude classes of errors from being emailed (404 errors, for instance). We've implemented something similar here on our database servers so we can get Windows event errors emailed to us, but exclude event error codes that we aren't interested in.

Jamie

7/27/2011 10:43:17 AM
Gravatar
Total Posts 18439

Re: Application Error Emails

Hi Jamie,

Sorry but I'm not increasing the scope of this right now. This is being done as a step towards web farm support. You can configure smtp today but I have no solution to reduce the noise and that is a different goal than the one I'm working on for database logging right now.

Maybe after the database logging is done it will be possible for people to implement their own custom solutions to poll the log data and send email if errors that meet a criteria of their choosing.

Best,

Joe

7/27/2011 10:51:09 AM
Gravatar
Total Posts 18439

Re: Application Error Emails

Also by default I will be leaving it configured for file logging but will provide instructions how to configure it for database logging. One needs to consider what happens if there is a database problem that causes an error or in new installations when errors are logged before the setup page has created the tables. So it may be best to keep file logging in place even after configuring database logging. I will have to try catch swallow all errors inside the database logger without logging them since that would just cause recursive errors in an infinite loop.

Best,

Joe

7/27/2011 2:51:42 PM
Gravatar
Total Posts 18439

Re: Application Error Emails

Hi Jamie,

It occurred to me after pondering this a bit that the best way to implement an smtp log appender with custom filtering would be to copy the code for the log4net SMTPAppender and modify it and compile it into a class library. log4net is open source and the appender code is not all that complex. Copy the code change the namespace and compile it into your own class library then configure it in the log4net.config, verify it works and then start tinkering.

The thing that makes it messy is having to process the error detail string looking for things like "pagenotfound" because there isn't some unique error code to go by and the messiness is made more difficult because environments in different languages would have different error strings. This kind of thing makes it difficult for me to think about implementing as something included in mojoPortal, but for someone implementing something for their own specific needs and language it would not be difficult.

Best,

Joe

7/27/2011 4:17:56 PM
Gravatar
Total Posts 1196
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Application Error Emails

Thanks for following that up, Joe. I agree, it makes sense to have it as something optional or left to custom development since there aren't real event codes to key off of.

9/12/2011 10:39:34 AM
Gravatar
Total Posts 130

Re: Application Error Emails

Hello,

I just got around to fiddling with the log4net.config file to see about having error emails sent to me and seem to be having trouble.  I've been on the Apache website and read about configuring the SmtpAppender but am still not receiving emails. I'm 100% sure that my host & port info is correct.  I'm wondering if there is anything else I need to adjust elsewhere in the project besides the log4net.config file to get the smtpAppender working.  It looks like my settings in the config file are accurate (does anyone see anything out of place?):

<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
      <to value="myemail@ufl.edu" />
      <from value="myotheremail@ufl.edu" />
      <subject value="mojoPortal Warning-Error Log" />
      <!--<Username value="" />
    <Password value="" />-->
      <smtpHost value="myhost.ufl.edu" />
      <Port value="25" />
      <bufferSize value="512" />
      <lossy value="true" />
      <threshold value="WARN"/>

      <filter type="log4net.Filter.LevelRangeFilter">
        <levelMin value="WARN" />
        <levelMax value="FATAL" />
      </filter>

      <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>

Thanks for any input/advice you may have to offer!

 

~ Beth

9/12/2011 11:00:19 AM
Gravatar
Total Posts 18439

Re: Application Error Emails

Hi Beth,

Try setting the buffer size to 1. The buffer is how many errors it will capture before logging, so with a buffer size of 512 it would collect 512 errors and then send you an email about them. If you want 1 log event per message then a buffer size of 1 should do that.

Hope that helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.