Labels

Wednesday, July 4, 2012

JBoss start up configuration - Setting Server properties using the Properties Service

Setting Server properties using the Properties Service


One cool way to add a list of System properties to JBoss is the Properties MBean Service.
In the deployment folder look for "properties-service.xml". (if you don't have it in your release you can create it at any time) :

Now add your properties either in the URLList Attribute or in the Properties Attribute:


<server>
    <mbean code="org.jboss.varia.property.SystemPropertiesService"
      name="jboss:type=Service,name=SystemProperties">

    <attribute name="URLList">
      http://somehost/some-location.properties,
        ./conf/somelocal.properties
    </attribute>

    <attribute name="Properties">
       property1=This is the value of my property
       property2=This is the value of my other property
    </attribute>

</server>



As you can see the The "URLList" is a comma-separated list of URL strings from which to load properties file-formatted content while the "Properties" is a specification of multiple property name=value pairs

Now you can access your properties with standard:

System.getProperty("property1");


Logging the startup process


JBoss uses the Log4jService (in JBoss AS 5.x and earlier) or the LoggingService (in JBoss AS 6.x and later) to configure logging.

However this service is not configured until after the bootstrap phase.

During the bootstrap the microkernel logs into log/boot.log using the configuration defined in log4j.properties (in 5.x and earlier) or logging.properties (in 6.x and later) contained in $JBOSS_HOME/bin/run.jar.


If you want to customize the boot loggin you have basically two options:
  • Change the configuration inside run.jar 
  • Use a system property to reference an outside configuration file.

The simplest strategy is to un-jar $JBOSS_HOME/bin/run.jar, change the appropriate properties file and re-jar. (We suggest you using the Open Source archiving software 7-zip which does a good job at editing files inside of archives).

Alternatively, you can also specify the boot log configuration at the command line, instead of editing run.bat/run.sh, for example:



run.bat -Dlog4j.configuration=file:./log4j.properties

or for the release 6.x :



run.bat -Dlogging.configuration=file:./logging.properties

No comments:

Post a Comment