Question

I have an Interceptor used for logging purposes. Now I want to give the admin the option to enable/disable logging. I could use application server parameters for that but I don't know how to access them during runtime. Would create a bean for that or a producer for that boolean and inject it into my interceptor.

Currently I am using JBoss, but I probably change to Glassfish. Is there a way to cover each of them?

No correct solution

OTHER TIPS

Well, enabling/disabling logging is normally something you do by the logging configuration (setting log level).

Though you might also use JMX and register your Beans in the MBeanServer to call whatever method you like from outside JBoss (ie by JConsole or any other JMX client). But be aware, every Bean instance has to be registered, so speaking of EJBs there might be multiple. I once solved this by having one Singleton EJB for every SessionBean working as the MBean serving/saving parameters and informations from every instance.

You can also use system properties. You can set those via the jboss-cli and query them in you code with System.getProperty(...). For the special case of logging, each application server provides a manageable log system to your application. For example, if you application uses slf4j you can configure the log level at runtime with jboss-cli in the logging subsystem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top