I have a mbean for a class say foo.bar.Log4j and I want to use jolokia to list all loggers?
I have tried reading on https://jolokia.org/reference/pdf/jolokia-reference.pdf but that tells me how to get values of predefined java.memory etc
Please suggest on how to get jolokia to retrieve loggers for a user-defined class
You have to keep in mind that even if your mbean is a singleton in your servlet, your servlet could be running on multiple endpoints - that's why the namespace alone is not sufficient to identify your mbean instance.
If you want to get all instances of foo.bar.Log4j
, you can use the read
endpoint like this:
http://yourserver/jolokia/read/foo.bar.Log4j:*
In general, you can get a list of all your available mbeans like this:
http://yourserver/jolokia/list
You should end up with a large json document that contains everything you might want to fetch. You will see things like
"foo.bar.Log4j": {
"name=foo,type=MyLogger": {
"desc": ...
"attr": {
...
}}}
You can now get the attributes using something like this:
http://yourserver/jolokia/read/foo.bar.Log4j:type=name=foo,type=MyLogger
In addition to type
and name
, you may see other fields as well, for example context
or id
. This a:b key is the Java ObjectName for your mbean.