Error notification on plone 4

2019-03-19 16:23发布

问题:

I just want to have email notification when an error is declared in plone 4.

Any ideas of product or any "how-to" ?

Thanks

回答1:

You can easily configure the built-in email notification for Zope, but we found that adding the mailinglogger package makes the emails a lot more managable.

The package adds:

  • customisable and dynamic subject lines for emails sent
  • emails sent with configurable headers for easy filtering
  • flood protection to ensure the number of emails sent is not excessive
  • support for SMTP servers that require authentication
  • configurable log entry filtering

The plone.recipe.zope2instance buildout recipe supports mailinglogger out of the box; simply define a mailinglogger variable in your [instance] part and include the mailinglogger egg:

[instance]
recipe = plone.recipe.zope2instance
eggs +=
    mailinglogger
# Other options go here
mailinglogger =
  <mailing-logger>
    level warning
    flood-level 100000
    smtp-server localhost
    from logger@example.com
    to error-receiver@example.com
    subject [ServerName Error] [%(hostname)s] %(levelname)s - %(line)s
  </mailing-logger>

The package has been invaluable for us on larger clusters, where we configure additional variables per instance to be included in the subject; we can see what instance the problem occurred on directly in the subject.



回答2:

Configuring mailing-logger is documented at http://pypi.python.org/pypi/plone.recipe.zope2instance but I think that email log notification is built into recent Zope2 releases, so you should now add the following to you [instance] section:

event-log-custom =
  <email-notifier>
    from server@here.com
    to kdie@localhost
    subject "anything goes here"
    smtp-server 127.0.0.1
  </email-notifier>

(example from http://myzope.kedai.com.my/blogs/kedai/44)



回答3:

http://pypi.python.org/pypi/collective.logbook is handy too.



回答4:

You need to add an email-notifier to your event-log-custom in buildout.cfg. Unfortunately there's no way to append it to your existing logging configuration but the following will mimic what plone.recipe.zope2instance does for the event log anyway

event-log-custom =
  <logfile>
    path ${buildout:directory}/var/log/${:_buildout_section_name_}.log
    level INFO
  </logfile>
  <email-notifier>
    from server@here.com
    to admin@company.com
    subject "[Zope alert - ${:_buildout_section_name_}]"
    smtp-server localhost
    level error
  </email-notifier>  


标签: plone zope