06-20-05 11:10 PM
public class Log4JWAS51Service implements CustomService,
NotificationListener {
private Log logger = LogFactory.getLog(getClass());
public Log4JWAS51Service() {
super();
}
/*
* (non-Javadoc)
*
* @see
com.ibm.websphere.runtime.CustomService#initialize(java.util.Properties)
*/
public void initialize(Properties properties) throws Exception {
URL configFile = getClass().getResource("/log4j.properties");
if (configFile != null) {
logger
.info("Log4JWAS51Service.initialize() configuring Log4J to use
configFile=["
+ configFile + "].");
LogManager.resetConfiguration();
PropertyConfigurator.configure(configFile);
NotificationFilterSupport filter = new NotificationFilterSupport();
filter.enableType(NotificationConstants.TYPE_J2EE_STATE_RUNNING);
ObjectName target = new ObjectName("WebSphere:*,type=Server");
AdminServiceFactory
.getAdminService()
.addNotificationListenerExtended(target, this, filter, null);
logger
.info("Log4JWAS51Service.initialize(): Waiting for system startup.");
} else {
logger
.fatal("Log4JWAS51Service.initialize() failed to configure Log4J, could
not find log4j.properties in classpath.");
}
}
/*
* (non-Javadoc)
*
* @see com.ibm.websphere.runtime.CustomService#shutdown()
*/
public void shutdown() throws Exception {
logger
.info("Log4JWAS51Service.shutdown() resetting log4j configuration.");
LogManager.resetConfiguration();
}
/*
* (non-Javadoc)
*
* @see
javax.management. NotificationListener#handleNotification(
javax.management.No
tification,
* java.lang.Object)
*/
public void handleNotification(Notification notification, Object argument)
{
// TODO Auto-generated method stub
logger
.info("Log4JWAS51Service.handleNotification(): System has started, done
with log handling.");
}
}
"Lee Francis Wilhelmsen" <leefw@start.no-n-o-s-p-a-m> wrote in message
news:d961j2$56kc$1@news.boulder.ibm.com...
> George Daswani wrote:
>
> Thanks for your reply. Yes, I would be interested in seeing sample code
> for the service if possible...
>
> Regards
> Lee Francis
[ Post a follow-up to this message ]
|