[Building Sakai] How to setup logging to send ERRORs by mail

Matvey Maslov matvey at sciworth.com
Thu Sep 30 06:39:16 PDT 2010


Hi guys,

  Thanks for the ideas - both are really helpful and useful.

Nuno,
  I've already tried to move mail.jar to common/lib - seems to work, but
somehow messages do not get delivered, probably some configuration issue.

Matthew,
  The approach you offered looks very promising - I'm really tired of these
finicky configuration problems of Sakai, so moving as much as possible
outside of Sakai really is the way to go in my opinion. I will start setting
up syslog-based system immediately.

Matvey

On Thu, Sep 30, 2010 at 4:22 PM, Matthew Jones <jonespm at umich.edu> wrote:

> Hi Matvey,
>
> I know I'd set something like this up before, but you might want to look at
> something simpler and external such as a log file monitor rather than
> incorporating it into these files. It would make it easier to change the
> rules on the fly (like if you get messages you want to filter out because
> you're getting spammed) and if there was a problem sending mail there might
> be an issue with the appender. This page talks about some of the advantages
> of separating logging request from taking action. [1]
>
> What we do at Michigan is us the syslog appender
> (org.apache.log4j.net.SyslogAppender) to consolidate all app servers logs on
> one remote "syslog" server. Then we monitor this combined log with swatch,
> [2] taking action (send email, etc) when any patterns match. Some errors are
> (unfortunately) common/expected so we don't need to know about them, others
> we are interested in. I believe that SMTPAppender also had some other
> limitations at the time (what types of messages it could send), so this
> worked out really good. Individual developers could set up their own swatch
> if they were monitoring for something specific.
>
> Splunk [3] also *looks* fancy if you wanted something to do some
> visualization, though I've just came across it recently and haven't used it.
>
> [1]
> http://www.johnandcailin.com/blog/john/how-setup-real-time-email-notification-critical-syslog-events
> [2] http://sourceforge.net/projects/swatch/
> <http://sourceforge.net/projects/swatch/>[3] http://www.splunk.com/
>  <http://www.splunk.com/>
> On Thu, Sep 30, 2010 at 6:03 AM, Nuno Fernandes <nuno at ufp.edu.pt> wrote:
>
>> Hi Matvey,
>>
>> This is something I also would like to have. However, I am not sure if
>> this is possible:
>>
>> The Log4J jar is located at TOMCAT/common/lib, which is the same location
>> is expects to find mail-*.jar library (I think this is what casues the "
>> NoClassDefFoundError" error on the logs)
>>
>> In fact, this mail-*.jar exists, but in TOMCAT/shared/lib/ which
>> apparently is not available to Log4J. Having this mail library duplicated on
>> both locations is wrong, and I'm not sure if moving the mail-*.jar to
>> common/lib will be OK too: Log4J should be able to find, but I don't know if
>> this won't bring issues with Sakai code using the mail-*.jar (like the email
>> service).
>>
>> Maybe you can try and report back your experiences to the community?
>>
>> Thanks,
>> Nuno
>>
>> On Thu, Sep 30, 2010 at 10:13 AM, Matvey Maslov <matvey at sciworth.com>wrote:
>>
>>> I'm trying to setup Log4j to send ERRORs by mail. To do this I changed
>>> log4j.properties in kernel-1.0.14 project
>>> (kernel-common/src/main/config/log4j.properties) to look like this:
>>> # use "A" for log in with catalina.out (actually standard output)
>>> log4j.rootLogger=WARN, Sakai, mail
>>> ...
>>> # Mail config
>>> log4j.appender.mail=org.apache.log4j.net.SMTPAppender
>>> log4j.appender.mail.To=<to address>
>>> log4j.appender.mail.From=<from address>
>>> log4j.appender.mail.SMTPHost=<smtp host>
>>> log4j.appender.mail.SMTPUsername=<smtp username>
>>> log4j.appender.mail.SMTPPassword=<smtp password>
>>> log4j.appender.mail.Threshold=ERROR
>>> log4j.appender.mail.BufferSize=1
>>> log4j.appender.mail.Subject=Sakai Error
>>> log4j.appender.mail.layout=org.apache.log4j.HTMLLayout
>>> ...
>>> (with valid data instead of <...> placeholders, of course).
>>>
>>> When I build and deploy the new version of kernel to Sakai 2.6.2, I get
>>> the following error in the logs:
>>>
>>> WARNING: Error creating bean with name
>>> 'org.sakaiproject.log.api.LogConfigurationManager' defined in file
>>> [/Users/matvey/Projects/sakai-tomcat/compone
>>> nts/sakai-kernel-component/WEB-INF/util-components.xml]: Invocation of
>>> init method failed; nested exception is java.lang.NoClassDefFoundError:
>>> Could n
>>> ot initialize class org.apache.log4j.LogManager
>>> org.springframework.beans.factory.BeanCreationException: Error creating
>>> bean with name 'org.sakaiproject.log.api.LogConfigurationManager' defined in
>>> f
>>> ile
>>> [/Users/matvey/Projects/sakai-tomcat/components/sakai-kernel-component/WEB-INF/util-components.xml]:
>>> Invocation of init method failed; nested exce
>>> ption is java.lang.NoClassDefFoundError: Could not initialize class
>>> org.apache.log4j.LogManager
>>> Caused by: java.lang.NoClassDefFoundError: Could not initialize class
>>> org.apache.log4j.LogManager
>>>         at org.apache.log4j.Logger.getRootLogger(Logger.java:135)
>>>         at
>>> org.sakaiproject.log.impl.Log4jConfigurationManager.init(Log4jConfigurationManager.java:106)
>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>         at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>         at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>         at java.lang.reflect.Method.invoke(Method.java:597)
>>>         at
>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java
>>> :1240)
>>>         at
>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1205
>>> )
>>>         at
>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
>>>         at
>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
>>>         at
>>> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
>>>         at
>>> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
>>>         at
>>> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
>>>         at
>>> org.sakaiproject.util.NoisierDefaultListableBeanFactory.getBean(NoisierDefaultListableBeanFactory.java:115)
>>>         at
>>> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
>>>         at
>>> org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)
>>>         at
>>> org.sakaiproject.util.SakaiApplicationContext.onRefresh(SakaiApplicationContext.java:90)
>>>         at
>>> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
>>>         at
>>> org.sakaiproject.component.impl.SpringCompMgr.init(SpringCompMgr.java:146)
>>>         at
>>> org.sakaiproject.component.cover.ComponentManager.getInstance(ComponentManager.java:68)
>>>         at
>>> org.sakaiproject.component.cover.ComponentManager.get(ComponentManager.java:80)
>>>         at org.sakaiproject.dav.DavServlet.init(DavServlet.java:500)
>>>         at javax.servlet.GenericServlet.init(GenericServlet.java:212)
>>>         at
>>> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
>>>         at
>>> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
>>>         at
>>> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
>>>         at
>>> org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
>>>         at
>>> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
>>>         at
>>> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
>>>         at
>>> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
>>>         at
>>> org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
>>>         at
>>> org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
>>>         at
>>> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
>>>         at
>>> org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
>>>         at
>>> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
>>>         at
>>> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
>>>         at
>>> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
>>>         at
>>> org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
>>>         at
>>> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
>>>         at
>>> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
>>>         at
>>> org.apache.catalina.core.StandardService.start(StandardService.java:448)
>>>         at
>>> org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
>>>         at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>         at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>         at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>         at java.lang.reflect.Method.invoke(Method.java:597)
>>>         at
>>> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
>>>         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
>>>
>>> Please help to set the logging properly. Thanks a lot! :)
>>>
>>>
>>> _______________________________________________
>>> sakai-dev mailing list
>>> sakai-dev at collab.sakaiproject.org
>>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>>
>>> TO UNSUBSCRIBE: send email to
>>> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
>>> "unsubscribe"
>>>
>>
>>
>>
>> --
>> Nuno Fernandes  .  { Analyst/Programmer }
>>
>> || web  . { http://www.ufp.pt  |  http://tinyurl.com/nfgrilo  |
>> follow_me @ nfgrilo }
>> || work . { Universidade Fernando Pessoa  |  Praça 9 de Abril, 349  |
>> 4249-004 Porto }
>>
>> _______________________________________________
>> sakai-dev mailing list
>> sakai-dev at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>
>> TO UNSUBSCRIBE: send email to
>> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
>> "unsubscribe"
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20100930/7a7502f4/attachment.html 


More information about the sakai-dev mailing list