Specialized Administration > Site Maintenance > Using Java Management Extensions (JMX) > Configuring JMX Email Notifications for Method Server Log Messages
Configuring JMX Email Notifications for Method Server Log Messages
Windchill can be configured to automatically email method server log entries as they are made. These notifications can be configured for any log4j message.
The following example shows how to configure notifications using the Windchill JMX Emailer Mbean.
Identify a class or package in the log from a log message
Find the message in the method server log, and identify the class or package that sent the message. For this example, the queue is stopped in order to force a message to be set to the log.
1. Log in to Windchill as a site administrator and go to Site > Utilities > Queue Management.
2. Select any queue and stop it. For this example, stop the commonProcessQueue.
3. Open the method server log and find the message informing that the queue was stopped. Identify the class that was the source of the message. In this example, the class is wt.jmx.notif.queue. Here is the example log entry:
2013-11-26 10:34:27,276 WARN [QueueCheckerThread-27] wt.jmx.notif.queue - Time=2013-11-26 16:34:27.272 +0000, Name=QueueNotifier, SourceObjectName=com.ptc:wt.subsystem=Monitors,wt.monitorType=Queues,Name=commonProcessQueue, class=class javax.management.Notification, type=wt.queue.QueueWatcherMBean.queueStopped, userData=commonProcessQueue, message=Queue commonProcessQueue has been stopped, JVM Name=4389@bla-ce6-utf1063, Queue Info=[WaitingReadyEntries=0,ExecutionThreadLoggerName=,TotalThreshold=100,MinEntryExecTimeSeconds=0.0,AveEntryExecTimeSeconds=0.0,MinMinutesBetweenNotifications=60,EntryExecutionTimeThresholdSec=900,TotalEntries=0,LoggerLevel=,WaitingReadyThreshold=15,TotalExecutionTime=0,LoggerName=wt.queue.QueueWatcherImpl.commonProcessQueue,MaxEntryExecTimeSeconds=0.0,Name=commonProcessQueue,ExecutionThreadLoggerLevel=,TotalEntriesExecuted=0]
Configure log4j
Configure a log4j appender and the appropriate loggers (loggers for each class or package for which you want to send email).
1. Add the appender and loggers to the log4jMethodServer.properties file. The following code sample shows the appender and loggers to add for the wt.jmx.notif.queue.
# Create a new appender that sends messages to a JMX MBean
appender.QueueEmailAppender.type=JMXAppenderPlugin
appender.QueueEmailAppender.name=JMXAppender

# Configure the class wt.jmx.notif.queue to use the
# QueueEmailAppender. The comma is important. It separates the
# (unspecified) level from the appender.
appender.QueueEmailAppender.filter.threshold.type=ThresholdFilter
appender.QueueEmailAppender.filter.threshold.level=WARN
# You may also want to specify a level threshold, so that log
# messages below the threshold are not emailed. ERROR would be a
# typical threshold, but in this case WARN has been selected for
# the demonstration.
logger.JMXNotifficationQueue.name=wt.jmx.notif.queue
logger.JMXNotifficationQueue.additivity=false
logger.JMXNotifficationQueue.appenderRef.QueueEmailAppender.ref=JMXAppender
logger.JMXNotifficationQueue.appenderRef.stdout.ref=stdout
logger.JMXNotifficationQueue.appenderRef.methodServerLogFile.ref=methodServerLogFile
2. Restart the method server, forcing it to re-read the log4jMethodServer.properties file.
Configure the Notification Handler Mbean
1. Start JConsole. For more information, see the section Getting Started with JConsole in JConsole.
2. Under Local Process, select wt.method.MethodServerMain.
3. Click Connect.
4. On the MBeans tab, navigate to com.ptc > Logging > Appenders and verify that QueueEmailAppender exists. If it is not present, you must create it before continuing.
5. On the MBeans tab, navigate to com.ptc > NotificationHandlers > Operations > addNotificationHandler and create a new notification handler.
a. In the handlerName field, enter the name you want to give the handler. For this example, use QueueEmailNotificationHandler.
b. In the targetMBeanObjectName field, enter the name of the log4j appender. For this example, use com.ptc:wt.subsystem=Logging,log4jType=Appenders,name=JMXAppender.
c. Click addNotificationHandler.
6. Open the QueueEmailNotificationHandler MBean you just created in JConsole and configure it as follows:
a. Set the EmailSubject attribute.
b. Set the EmailRecipientListName attribute to QueueEmailList.
Create an email list
1. Navigate to the com.ptc > Emailer MBean and use Operations > addEmailList to create an email list named QueueEmailList.
2. Navigate to the com.ptc > Emailer MBean and select EmailLists. Configure the QueueEmailList by adding your email address to the AddressList attribute.
Test it
The method server is now configured to send email to you when it logs a message from the wt.jmx.notif.queue package. You can test this by stopping a queue, as in Identify a package in the log from a log message. When you stop the queue, you should receive the log message in email.
Was this helpful?