WebLogic Notifications – Watch the Log and Send Email
By james.bayer on Jul 15, 2010
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. In this case, my colleague Sherwood wanted to get an email when the message indicating that an SSL certificate is going to expire within 30 days is written to the log. 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.
Configure a Mail Session
Configure a Diagnostic System Module
The console docs again give you the step-by step, make sure you target it at your server.
Once you have the system module in place, then configure a Notifcation that references the Mail Session you set up previously. You can see from the screenshot that there is an easy way to change the subject and body of the email. Click to enlarge.
Then configure a Log Watch that uses the Notification. In my server log, the message looks like this:
So that means we should use the expression builder to look for this particular message id. Remember, WebLogic is multi-lingual, so instead of looking for the hard-coded text, just search for the unique ID of the untranslated log message.
The last step is a gotcha I missed the first time. The log message we are searching for is at a “Notice” level. By default Log Watches only are fired against “Warning” and higher (I think – I forgot what the default was). You need to change it on the “Watches and Notifications” tab of the Diagnostic System Module. Click to enlarge.
That should be it, restart the server so that the message is logged and check your email. Click to enlarge.
Of course WLDF can do a lot more sophisticated notifications too. In addition to email possible notifcation actions are JMS, JMX, SNMP traps, and capturing a system diagnostic image. The watches can be more sophisticated too, such as watching JMX attributes which is described in this other blog. If you have any issues, it can be useful to enable “Debug” of the parts of the diagnostics subsystem in your Server configuration and check out the log messages.