LifeCycle events (like in your example) can be monitored using a LifeCycle.Listener.
package jetty.examples;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.preventers.LoginConfigurationLeakPreventer;
public class LifecycleEvents
{
public static class EventCapture implements LifeCycle.Listener
{
@Override
public void lifeCycleStarting(LifeCycle event)
{
System.out.printf("[starting] %s%n",event);
}
@Override
public void lifeCycleStarted(LifeCycle event)
{
System.out.printf("[started] %s%n",event);
}
@Override
public void lifeCycleFailure(LifeCycle event, Throwable cause)
{
System.out.printf("[failure] %s%n",event);
cause.printStackTrace();
}
@Override
public void lifeCycleStopping(LifeCycle event)
{
System.out.printf("[stopping] %s%n",event);
}
@Override
public void lifeCycleStopped(LifeCycle event)
{
System.out.printf("[stopped] %s%n",event);
}
}
public static void main(String[] args) throws Exception
{
LoginConfigurationLeakPreventer component = new LoginConfigurationLeakPreventer();
EventCapture capture = new EventCapture();
component.addLifeCycleListener(capture);
component.start();
System.out.printf("isRunning: %b%n",component.isRunning());
component.stop();
}
}
That would be a better choice than using the logging event messages.
This way could also distinguish between different instances of the same object type as well.