• WLS
    July 15, 2010

WebLogic Notifications – Watch the Log and Send Email

Guest Author

emailCan 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

The console docs give you the step-by-step.  Here’s what mine looks like – don’t forget to target it at all of your servers.  I use Apache James as mail server on my localhost.  Click to enlarge.


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:

####<Jul 15, 2010 8:16:46 PM CDT> <Notice> <WebLogicServer> <jbayer-us> <AdminServer> <main> <<WLS Kernel>> <> <> <1279243006546> <BEA-000360> <Server started in RUNNING mode>

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.

ruleExpression ruleExpression [2]

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.

Screencast following the procedure above

Join the discussion

Comments ( 17 )
  • Rai Saturday, July 17, 2010
    Thanks for this detailed steps. Do you how do we pass the password
    for the smtp server which requires the authentication?
    I tried mail.smtp.user and mail.smtp.password, it does'nt seems to work
  • james.bayer Sunday, July 18, 2010
    I'm not sure the WebLogic Mail Session can be configured to use SMTP Auth without making some API calls since it simply uses java mail properties. Looking at the Java Mail properties page, there isn't a property for the password, just the mail.smtp.auth=true and mail.smtp.user=username
    So it looks like you can do it with the API calls by calling the Transport.connect(username,password) method. You can get the Transport reference from the Session. You may also be able to use an Authenticator, here's what I would try first.
    1) Use JNDI to get the reference to the Mail Session
    2) Get the Transport object and call connect
    Transport tr = session.getTransport("smtp");
    tr.connect(username, password);
    msg.saveChanges(); // don't forget this
    tr.sendMessage(msg, msg.getAllRecipients());
    See here:
    and here:
    and here:
    Good luck,
  • Rai Sunday, July 18, 2010
    I could do this programmatically, however we could not make use of the bulit-in wldf notification option. Also I tried to create JMS notification for an event and put this email notification code inside an MDB. That works, However In-case of JMS notification jms message content has just jms Message ID. Is there any way we can include the error/warning code BEA-36000, BEA-000337 etc?
  • james.bayer Monday, July 19, 2010
    That's a good point about WLDF email notification and I'll check with the team about that and the JMS message contents. I'll let you know what I find out.
  • Craig Tuesday, August 3, 2010
    Do you know how to access the Health State, not the State (Running)?
    The health state usually says 'OK' but I want to be notified of when it's NOT OK.
  • james.bayer Tuesday, August 3, 2010
    Craig, I have two thoughts without having had time to try anything.
    1) See if you can adjust the log level to get Health changes logged and take action whenever the Health is not ok
    2) if #1 has issues, try using the JMX Watch mechanism instead of the Log Watch
    I'll update this if I have a chance to try any of these in the future.
    Good luck, James
  • Craig Wednesday, August 4, 2010
    Hi James,
    Thanks for the response. As I am a newbie to wls please bare with me - sorry.
    Adjust the log level - is through the admin console? If so could do with a little more info.
    I should be OK with JMX watch.
  • james.bayer Wednesday, August 4, 2010
    Craig, It probably depends on what your use-case is. Can you describe it? For example, if your Watch is on the managed server that has ownership of the log, then you can probably look at this page:
    Search for WL-000385
    There are other relevant log messages there that also cover various failure conditions. But if the server health is bad, you may not want to depend on that server to notify you of issues. In this case the log for server health is CRITICAL - so I don't think log level adjustment is required.
    If you want the Admin Server to Watch and Notifiy when the state of one of it's managed servers is not OK, then the Harvester Watch (for JMX attribute monitoring) is likely what you want. See:
    I'm pretty tied up, but if I spend some time on this later on and can give a better example I will.
  • Phil Thursday, March 24, 2011
    Hi James,
    Thanks for the video... I have a SOA Suite 11g ( instance installed and had an issue where a problem occurred with the domain, causing the soa-infra composite application to go to a "Failed" state on my soa managed server.
    I could see the message from the FMW EM console but I'd like to get an Email notification sent out if this occurs in Production.
    Can this be used for that purpose? and if so, I could use some help in configuring and setting this up.
  • james.bayer Thursday, March 24, 2011
    I have not tried this with a SOA Suite application, but it sounds like you're not talking about a composite so much as the soa-infra application itself. I think configuring a Harvester Watch and Notification that looks at the application MBean state (which is what is showing in the FMW EM console) is how you would do this.
    For example, here is WLST showing that MBean:
    wls:/base_domain/serverRuntime/ApplicationRuntimes/HelloWorldEJB> cmo
    wls:/base_domain/serverRuntime/ApplicationRuntimes/HelloWorldEJB> cmo.getHealthState()
    Now you'd just have to write the correct Watch Rule, which I'm not sure exactly how to do in this case.
    You may want to ask the SOA Suite OTN forum to see if anyone has done this:
  • James Bayer Friday, March 25, 2011
    I found the MBean attributes for State and Health via WLST. In this example my application is called HelloWorldEJB
    State (ACTIVE, PREPARED, UNPREPARED) is like below, where 2 is ACTIVE in this case, although the docs aren't clear on that (we've filed some doc bugs to make this more clear in the future)
    wls:/base_domain/serverRuntime/ApplicationRuntimes/HelloWorldEJB> cmo
    wls:/base_domain/serverRuntime/ApplicationRuntimes/HelloWorldEJB> cmo.getActiveVersionState()
    Health (OK, FAILED, and probably others) is like:
    wls:/base_domain/serverRuntime/ApplicationRuntimes/HelloWorldEJB> cmo.getHealthState().getState()
    So now you can configure both a Watch and a Notification based on either of those. I'll probably add a blog entry on that as soon as I get some time. Hopefully this gets you going. You can use an Alarm so that you don't repeatedly get bothered by emails until a time period elapses too.
  • guest Wednesday, May 11, 2011
    Hi James,
    I am using my company's email client(outlook) to set up smtp info in mail session ; but i haven't received alerts. I did exactly as you suggested....Also, what do i do if i need to set some more different types of alerts. Is there any other blog with all the different alerts i could configure?
  • james.bayer Thursday, May 12, 2011
    Your company SMTP server may require authentication, which I don't think is supported. I believe the WLS SMTP support assumes that it is an open SMTP server. Try setting up a test SMTP server like Apache James to test the theory. You may have to check with the email team to see what options you have there. Regarding other types of alerts, you can base it on JMX metric thresholds, etc. I'm not aware of other write-ups in this area.
    Thanks, James
  • guest Wednesday, June 29, 2011

    Hi James,

    Do I need a mail server inorder to work with mailsession feature.

    If yes, Please let me know how do I set up the same.

    Any help would be very much appreciated.



  • james.bayer Wednesday, June 29, 2011


    Yes you need to provide access to an SMTP server of some kind because WebLogic Server itself is not a mail server. I use Apache James for my testing. http://james.apache.org/

    They've written up how to use it here:


    Thanks, James

  • guest Saturday, July 2, 2011

    Hello James,

    Thanks for the clarification. I have 5 server running on 5 different hosts and Would I be able to monitor all the 5 servers with watches and notification feature? If yes, Please let me know how can I do that.

    Appreciate your prompt response!


    Vijay R

  • james.bayer Monday, July 4, 2011

    Vijay, It's simple. Just follow the same approach described and use the "target" feature of the Mail Session and WLDF System Modules to target them at each of the 5 servers. Thanks, James

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.