linux script

I need to write a script to which need to track errors in log and need to check last 100 lines in the log at every 5 minits. if error fund need to mail my self
error type

  1. "STATE_ADMIN" if found need to print: <Jan 5, 2011 11:47:02 AM IST><ewaps2> <ADFAPPS2> <[ACTIVE] STATE_ADMIN

2."Java heap space" if found need to print:<Jan 5, 2011 11:19:53 AM IST><ewaps2> <ADFAPPS2>Java heap space

3."FAILED" if found need to print :<Jan 18, 2011 2:30:39 PM IST> <Critical> <Health> <ewaps2> <ADFAPPS2>FAILED

+++++++++++++++++++++++++++++++++++++++++++++++++++++=
log format:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

####<Jan 5, 2011 11:19:53 AM IST> <Info> <EJB> <ewaps2> <ADFAPPS2> <[ACTIVE] ExecuteThread: '39' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <BEA1-62083AE18EE1CCA374D0> <> <1294206593150> <BEA-010227> <EJB Exception occurred during invocation from home or business: weblogic.ejb.container.internal.StatelessEJBHomeImpl@207d6e55 threw exception: java.lang.OutOfMemoryError: Java heap space>
####<Jan 5, 2011 11:20:11 AM IST> <Info> <EJB> <ewaps2> <ADFAPPS2> <[ACTIVE] ExecuteThread: '29' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <BEA1-620B3AE18EE1CCA374D0> <> <1294206611066> <BEA-010227> <EJB Exception occurred during invocation from home or business: weblogic.ejb.container.internal.StatelessEJBHomeImpl@207d6e55 threw exception: java.lang.OutOfMemoryError: Java heap space>
####<Jan 5, 2011 11:47:02 AM IST> <Info> <Deployer> <ewaps2> <ADFAPPS2> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1294208222623> <BEA-149059> <Module vch.war of application vch is transitioning from STATE_ADMIN to STATE_ACTIVE on server ADFAPPS2.>
####<Jan 5, 2011 11:47:02 AM IST> <Info> <Deployer> <ewaps2> <ADFAPPS2> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1294208222623> <BEA-149060> <Module vch.war of application vch successfully transitioned from STATE_ADMIN to STATE_ACTIVE on server ADFAPPS2.>
####<Jan 18, 2011 2:30:39 PM IST> <Critical> <Health> <ewaps2> <ADFAPPS2> <[ACTIVE] ExecuteThread: '41' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1295341239041> <BEA-310006> <Critical Subsystem Thread Pool has failed. Setting server state to FAILED.
####<Jan 18, 2011 2:30:39 PM IST> <Notice> <WebLogicServer> <ewaps2> <ADFAPPS2> <[ACTIVE] ExecuteThread: '41' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1295341239053> <BEA-000365> <Server state changed to FAILED>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pl help me to do this
thanks
ashwan