|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ecyrd.speed4j.log.Log
com.ecyrd.speed4j.log.Slf4jLog
com.ecyrd.speed4j.log.PeriodicalLog
public class PeriodicalLog
A Periodical log which can also expose its attributes via JMX.
The JMX name is based on the name of the Log. So if you don't set
it via Log.setName(String), you'll end up something that Speed4J
picks up on its own. Normally, if you use the property file to
configure Speed4J, this gets automatically assigned for you.
The PeriodicalLog starts a new Thread to collect the statistics. Don't forget to shut it down with a call to shutdown(),
or else you might risk a memory leak. This is a common problem with e.g. web applications, where redeployment
regularly causes these.
In a web app, you could set up your own ServletContextListener to ensure the proper shutdown:
class MyListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent sce) {}
public void contextDestroyed(ServletContextEvent sce) {
StopWatchFactory.getInstance("myLoggerName").shutdown();
}
}
PeriodicalLog adds its own JVM-wide shutdown hook, so you don't need to prepare for that.3
| Field Summary |
|---|
| Fields inherited from class com.ecyrd.speed4j.log.Slf4jLog |
|---|
m_log |
| Constructor Summary | |
|---|---|
PeriodicalLog()
Creates an instance of PeriodicalLog. |
|
| Method Summary | |
|---|---|
Object |
getAttribute(String attribute)
|
AttributeList |
getAttributes(String[] attributes)
|
MBeanInfo |
getMBeanInfo()
|
Object |
invoke(String actionName,
Object[] params,
String[] signature)
|
void |
log(StopWatch sw)
Logs using the INFO priority. |
void |
setAttribute(Attribute attribute)
|
AttributeList |
setAttributes(AttributeList attributes)
|
void |
setJmx(String value)
Set the tags which are shown via JMX. |
void |
setPeriod(int periodSeconds)
Set the logging period in seconds. |
void |
shutdown()
Shuts down the collector thread and removes the JMX bean if it is registered. |
| Methods inherited from class com.ecyrd.speed4j.log.Slf4jLog |
|---|
setSlf4jLogname |
| Methods inherited from class com.ecyrd.speed4j.log.Log |
|---|
getName, isEnabled, setEnable, setName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PeriodicalLog()
| Method Detail |
|---|
public void log(StopWatch sw)
Slf4jLog
log in class Slf4jLogsw - The StopWatch to log.public void setJmx(String value)
value - A comma-separated list of tags which are shown via JMX.public void shutdown()
shutdown in class Logpublic void setPeriod(int periodSeconds)
periodSeconds - The period in seconds.
public Object getAttribute(String attribute)
throws AttributeNotFoundException,
MBeanException,
ReflectionException
getAttribute in interface DynamicMBeanAttributeNotFoundException
MBeanException
ReflectionExceptionpublic AttributeList getAttributes(String[] attributes)
getAttributes in interface DynamicMBeanpublic MBeanInfo getMBeanInfo()
getMBeanInfo in interface DynamicMBean
public Object invoke(String actionName,
Object[] params,
String[] signature)
throws MBeanException,
ReflectionException
invoke in interface DynamicMBeanMBeanException
ReflectionException
public void setAttribute(Attribute attribute)
throws AttributeNotFoundException,
InvalidAttributeValueException,
MBeanException,
ReflectionException
setAttribute in interface DynamicMBeanAttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionExceptionpublic AttributeList setAttributes(AttributeList attributes)
setAttributes in interface DynamicMBean
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||