users@glassfish.java.net

Re: A way to receive mail when severe message in the server.log appear

From: <glassfish_at_javadesktop.org>
Date: Mon, 29 Sep 2008 03:35:07 PDT

I'm documenting about self_management_rules.
http://blogs.sun.com/technical/entry/self_management_rules

So, in order to accomplish in notification a SEVERE log message in server.log I make

1) a custom MBEAN

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.management.*;

public class LogListener implements LogListenerMBean, NotificationListener {

    public LogListener(){
    }

    public void handleNotification(Notification notification, Object handback)
    {
        //If it works I change it with a send mail code with java mail session..
        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "MY EVENT", "");
    }
}

public interface LogListenerMBean { }

2) I make in admin console a managment rule (see attachment for screenshot)

3) I make a servlet that by calling it in a browser make a SEVERE message

Logger.getLogger("TEST").log(Level.SEVERE, "LOG A TEST MSG", "");

But I can't set a in management rule configuration a global Logger that notify my MBean on every SEVERE message.

So the only way is to change the code above in
Logger.getLogger("global").log(Level.SEVERE, "LOG A TEST MSG", "");
and set in management rule configuration "global" Logger.

How Can Avoid this limitation?
I wish to set a really global logger in order to notify for all SEVERE message
[Message sent by forum member 'peppeme' (peppeme)]

http://forums.java.net/jive/thread.jspa?messageID=302307