Tuesday, January 25, 2011

WebLogic Notifications – Watch the Log and Send Email

Can WebLogic send an email when a certain message shows up in the WLS log?  The answer is yes and it is pretty straight-forward to configure. The WebLogic Diagnostic Framework or WLDF enables this capability with a sub-feature called Watches and Notifications.  Here is a real simple example to get an email when the server starts in a RUNNING state


Configuring an Email notification consists of three parts

A) Creating a New Mail Session
B) Configuring WLDF Module
c) Configuring Watch and Notification

A) Creating a New Mail Session

Domains->Services->Mail sessions

 
Please configure the mail server and/or fill out the JavaMail Properties with existing mail server information.

Refer [JAMES mail server, http://james.apache.org/] to configure new Mail server


Click Finish and a new mail session called MYMailSession will be created.


B)WLDF Module Configuration :

 Diagnostics–>Diagnostic Modules


Create a New DiagnosticModule
Name: MyDiagnosticModule —> Finish and Activate Changes.


C) Configuring Watch And Notification :
1) Configuring Notification
Dianostic Module -> MyDiagnosticModule->Watches and Notifications ->Notifications tab


Create new notification -> MyNotification ----NEXT




Choose the Mail session name that we previously configured and enter the e-mail recipient details and Finish



2) Configuring Watch

Dianostic Module -> MyDiagnosticModule->Watches and Notifications ->Watch tab



Click NEW



NEXT -> ADD EXPRESSIONS

We have selected the Watch Type: Server Log, weblogic logs have specific code for each of the logs, for example during the start up, when the server comes to RUNNING status , the NOTICE that gets logged is BEA-000360 and BEA-002607, when server shuts down. We can make use of this weblogic log codes for setting up the watch rule.

<Oct 21, 2010 4:05:27 AM GMT> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>

We will setup a notification if the server goes to shutdown state; BEA-002607

By Default the log severity will be “Warning”, please change the severity to “Notice”








Choose the arrow to select the available Notification that we’ve created earlier and click Finish and Activate changes


Ensure that your Diagnostic module is targeted to the required server (this ex :Admin)


If the server goes down and comes back RUNNING, the watch will be triggered and we will receive an e-mail


2 comments:

Vijay Naik said...

Super Sunil...I was looking for something like this for long...Thx a lot for this blog...Keep blogging the weblogic issues that u get.

Vijay Naik.

Peer to Peer Study said...

Hi,

How to configure, if the server is completely down and we need to trigger an email if it was down. Not to trigger after it came back to running mode?