6 Replies Latest reply on Jul 11, 2012 5:23 PM by davidmac

    JBoss 7.1 Domain Mode Logging - configuring per instance log locations

    davidmac

      We have a security policy that requires the JBoss installation (in Linux) to be installed under /home/someuser, but that partition isn't very big so we need logging output to go somewhere under /var/log/*.  So suppose we have 2 controlled server instances (S1 and S2) that live here (within the home directory):

       

      jboss/domain/servers/S1

      jboss/domain/servers/S2

       

      With this setup (having not changed the logging config) we get these logs on the home partition:

       

      jboss/domain/log/host-controller.log

      jboss/domain/log/process-controller.log

       

      jboss/domain/servers/S1/log/server.log

      jboss/domain/servers/S1/log/boot.log

       

      jboss/domain/servers/S2/log/server.log

      jboss/domain/servers/S2/log/boot.log

       

      We need to configure:

       

      • Domain logs (jboss/domain/log/*) to go to /var/log/jboss.
      • S1's logs (jboss/domain/servers/S1/log/*) to go to /var/log/S1
      • S2's logs (jboss/domain/servers/S1/log/*) to go to /var/log/S2

       

      It seems like some approach to setting jboss.server.log.dir in various scopes in the management console (or config file) would work but it isn't clear if they would conflict or get overridden properly.  My assumption for dealing with S1 and S2 is to set the jboss.server.log.dir system property independently on each server configuration's system properties.  Should that work?

       

      How to set the location of the domain logs?

       

      Or have you come up with a better approach or practice?  (Eventually we want to log to a central logging location ala syslog appender or some such).

       

      Note that we don't want to resort to using symlinks as that would complicate configuration management.

       

      Thanks for any pointers.

        • 1. Re: JBoss 7.1 Domain Mode Logging - configuring per instance log locations
          jamezp

          In your host.xml on the servers tag add the directory-grouping="by-type" attribute.

           

           

          <servers directory-grouping="by-type">
              <server name="server-one" group="main-server-group" auto-start="true"/>
              <server name="server-two" group="main-server-group" auto-start="true">
                  <socket-bindings port-offset="150"/>
              </server>
              <server name="server-three" group="other-server-group" auto-start="false">
                  <socket-bindings port-offset="250"/>
              </server>
          </servers>
          
          

           

           

          You could also execute a CLI command to change it as well.

           

          ${JBOSS_HOME}/bin/jboss-cli.sh --connect "/host=master:write-attribute(name=directory-grouping,value=by-type)"
          

           

          What at attribute does is changes the way the tmp, log and data directories are created. So the log directory for server-one would be:

           

          ${JBOSS_HOME}/domain/log/servers/server-one
          

           

          You can also override the jboss.server.log.dir to /var/log/jbossas or whatever you want.

           

          --

          James R. Perkins

          1 of 1 people found this helpful
          • 2. Re: JBoss 7.1 Domain Mode Logging - configuring per instance log locations
            davidmac

            Thanks, that is very helpful.  One clarification and I'll be ready to test: 

             

            Where is the proper place(s) to put the jboss.server.log.dir setting so that all the processes (host controller, process controller, server instances) will have that property correctly set to "/var/log/jbossas"?  I know I can set the system property in the host.xml/servers/server scope but that won't cover the host controller and process controllers.

            • 3. Re: JBoss 7.1 Domain Mode Logging - configuring per instance log locations
              jamezp

              You can either pass it as a system propertry, -Djboss.server.log.dir=/var/log, or add the system property like you suggest and edit the logging.properties file for the boot.log. Just adding it to the JAVA_OPTS in domain.conf would work too.

               

              --

              James R. Perkins

              • 4. Re: JBoss 7.1 Domain Mode Logging - configuring per instance log locations
                davidmac

                Well I didn't get very far... almost nothinged work as expected   BTW, this is 7.1.1 Final.  I modified the logging.properties and got the boot.log file into /var/log/erp/boot.log.  But...

                 

                I made the mods to host.xml shown below (only showing relevant portions):

                 

                <?xml version='1.0' encoding='UTF-8'?>

                <host name="S1" xmlns="urn:jboss:domain:1.2">

                        <servers directory-grouping="by-type">

                                <server name="instance1" group="group1">

                                        <system-properties>

                                                <property name="com.blah" value="blah1"/>

                                        </system-properties>

                                        <jvm name="default">

                                        </jvm>

                                </server>

                        </servers>

                </host>

                 

                When I started the the server using ./domain.sh I got the following error:

                 

                ERROR [org.jboss.as.host.controller] (Controller Boot Thread) JBAS010907: Failed to start server (instance1) java.lang.IllegalArgumentException: No enum constant org.jboss.as.host.controller.DirectoryGrouping.by-type

                 

                A second issue is that the jboss.server.log.dir didn't seem to take effect even though it is in domain.conf:

                 

                if [ "x$JAVA_OPTS" = "x" ]; then

                   JAVA_OPTS="-Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.d

                gc.server.gcInterval=3600000"

                   JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"

                   JAVA_OPTS="$JAVA_OPTS -Djboss.domain.default.config=domain.xml -Djboss.host.default.config=host.xml"

                   JAVA_OPTS="$JAVA_OPTS -Djboss.server.log.dir=/var/log/erp"

                else

                   echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"

                fi

                 

                # Use JBoss Modules lockless mode

                #JAVA_OPTS="$JAVA_OPTS -Djboss.modules.lockless=true"

                 

                # The ProcessController process uses its own set of java options

                if [ "x$PROCESS_CONTROLLER_JAVA_OPTS" = "x" ]; then

                    PROCESS_CONTROLLER_JAVA_OPTS="$JAVA_OPTS -Djboss.server.log.dir=/var/log/erp"

                fi

                 

                # The HostController process uses its own set of java options

                if [ "x$HOST_CONTROLLER_JAVA_OPTS" = "x" ]; then

                    HOST_CONTROLLER_JAVA_OPTS="$JAVA_OPTS -Djboss.server.log.dir=/var/log/erp"

                fi

                 

                I removed the "directory-grouping" attribute from host.xml since it was erroring and tried starting with just the changes to domain.conf to test them.  It didn't write the process controller or host controller log anywhere (i.e. jboss/domain/log or /var/log/erp).  However, it wrote the server.log to /var/log/erp/server.log.

                 

                Any ideas on what I'm doing wrong?

                • 5. Re: JBoss 7.1 Domain Mode Logging - configuring per instance log locations
                  jamezp

                  Well I need to apologize here. Looks like there was a bug there in how the attribute was parsed. How it passed testing, I'm not sure. It is fixed upstream, but not in any release accept EAP 6 so far. So it really is useless for you. Even worse I don't see a workaround for it other than building from source.

                   

                  I forgot in domain mode you also have to add -Djboss.domain.log.dir as well.

                   

                  --

                  James R. Perkins

                  • 6. Re: JBoss 7.1 Domain Mode Logging - configuring per instance log locations
                    davidmac

                    No apology necessary.  I appreciate the effort.  I'll figure out some workaround for now and then revisit in another few weeks.  I don't have a problem building from source except not time at the present.  If it still isn't working after another public release or 2 I'll build it from scratch and test.