7 Replies Latest reply on Dec 10, 2014 8:56 PM by James Perkins

    How can I redefine jboss.server.log.dir in domain mode?

    Scott Bass Newbie

      Hi,

       

      FWIW, I've Googled for *hours* before posting...

       

      I can edit domain.bat to redirect process-controller.log and host-controller.log.  These then just become command line options:

       

      rem Set the domain log dir
      if "x%JBOSS_LOG_DIR%" == "x" (
        set  "JBOSS_LOG_DIR=%JBOSS_BASE_DIR%\log"
      )
      ...
      "-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\process-controller.log" ^
      ...
      "-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\host-controller.log" ^
      

       

      However, I also want to redirect boot.log and server.log for the server instances.

       

      From domain.xml:

       

                      <periodic-rotating-file-handler name="FILE">
                          <formatter>
                              <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                          </formatter>
                          <file relative-to="jboss.server.log.dir" path="server.log"/>
                          <suffix value=".yyyy-MM-dd"/>
                          <append value="true"/>
                      </periodic-rotating-file-handler>
      

       

      From hosts.xml:

       

          <servers>
              <server name="Futrix1" group="Futrix-Group" auto-start="true">
                  <socket-bindings socket-binding-group="futrix-sockets" port-offset="200"/>
              </server>
              <server name="Futrix2" group="Futrix-Group" auto-start="false">
                  <socket-bindings socket-binding-group="futrix-sockets" port-offset="300"/>
              </server>
              <server name="Futrix9" group="Futrix-Group" auto-start="false">
                  <socket-bindings socket-binding-group="futrix-sockets" port-offset="900"/>
              </server>
          </servers>
      

       

      So here is where the servers are defined, but I can't see how to redefine jboss.server.log.dir so it has a different value for each server instance???

      Can I define jboss.server.log.dir in host.xml so that it will get picked up by domain.xml?  Do I need to move the file handler code to host.xml?

       

      I want the logs to go to:

       

      E:\Logs\Lev1\JBoss\Futrix1\boot.log
      E:\Logs\Lev1\JBoss\Futrix1\server.log
      
      E:\Logs\Lev2\JBoss\Futrix2\boot.log
      E:\Logs\Lev2\JBoss\Futrix2\server.log
      
      E:\Logs\Lev9\JBoss\Futrix9\boot.log
      E:\Logs\Lev9\JBoss\Futrix9\server.log
      

       

      respectively.

       

      I've read this, but there's no guidance re: moving the location of all the log files, esp. in domain mode:  https://docs.jboss.org/author/display/AS71/Logging+Configuration

       

      Any help greatly appreciated.  I've seen numerous Google hits re: standalone configuration, but none that addressed this issue in domain mode.

       

      If this isn't the correct forum for this question please advise alternatives.

       

      Thanks,

      Scott

        • 1. Re: How can I redefine jboss.server.log.dir in domain mode?
          James Perkins Master

          If the FutrixX is the name of the server then you can achieve something close with two changes. You'll need to change the directory-grouping parameter on your host to by-type.

          /host=master:write-attribute(name=directory-grouping,value=by-type)
          

           

          You'll need to restart and either add to the HOST_CONTROLLER_JAVA_OPTS in the domain.conf.bat -Djboss.server.log.dir=E:\Logs\Lev2\JBoss. You could optionally pass that as a command line parameter as well.

           

          Assuming the server names are Futrix you'll see a layout like the following:

          E:\Logs\Lev1\JBoss\servers\Futrix1\boot.log  
          E:\Logs\Lev1\JBoss\servers\Futrix1\server.log  
            
          E:\Logs\Lev2\JBoss\servers\Futrix2\boot.log  
          E:\Logs\Lev2\JBoss\servers\Futrix2\server.log  
            
          E:\Logs\Lev9\JBoss\servers\Futrix9\boot.log  
          E:\Logs\Lev9\JBoss\servers\Futrix9\server.log 
          

           

          I've filed an issue in WildFly Core to fix the issue by default if the value is set to by-server. Which should give you more of what you're looking for.

          --

          James R. Perkins

          • 2. Re: How can I redefine jboss.server.log.dir in domain mode?
            ksreen Newbie

            Have you tried starting with -Djboss.server.log.dir option domain.bat -Djboss.server.log.dir=C:\User\LogDir

            • 3. Re: How can I redefine jboss.server.log.dir in domain mode?
              James Perkins Master

              That could work, but if the group-by is set to by-server, the default, it will attempt to write everything into the same file for all servers which is not a good thing.

               

              --

              James R. Perkins

              • 4. Re: How can I redefine jboss.server.log.dir in domain mode?
                Scott Bass Newbie

                Hi All,

                 

                Thanks for the replies.  Very much appreciated.  Sorry for the delayed response, I was pulled onto other things.

                 

                jamezp:

                Apologies, I don't know where/how to set this:

                /host=master:write-attribute(name=directory-grouping,value=by-type)

                 

                Can you specify in which file (eg. domain.xml or host.xml) I would set this, preferably with a bit of context?

                 

                Also, will the below specify a different server directory for each server?  To me it looks like "E:\Logs\Lev2\JBoss" could be a typo???  It needs to be a different directory path for the three Futrix# servers defined in hosts.xml.

                 

                ...either add to the HOST_CONTROLLER_JAVA_OPTS in the domain.conf.bat -Djboss.server.log.dir=E:\Logs\Lev2\JBoss.

                 

                ksreen:

                I have to set a property for the futrix.war file in order for it to bootstrap its properties file location.  I worked that out by specifying <system-properties> in the hosts.xml file

                 

                So I tried using your approach in the same manner.  Here is an excerpt from my hosts.xml file:

                 

                    <servers>
                        <server name="Futrix1" group="Futrix-Group" auto-start="true">
                            <socket-bindings socket-binding-group="futrix-sockets" port-offset="200"/>
                            <system-properties>
                                <property name="jboss.server.log.dir" value="E:/Logs/Lev1/JBoss/Futrix1"/>
                                <property name="futrixweb.bootstrap.file-config.dir" value="E:/SAS/Config/Lev1/Futrix"/>
                            </system-properties>
                        </server>
                        <server name="Futrix2" group="Futrix-Group" auto-start="true">
                            <socket-bindings socket-binding-group="futrix-sockets" port-offset="300"/>
                            <system-properties>
                                <property name="jboss.server.log.dir" value="E:/Logs/Lev2/JBoss/Futrix2"/>
                                <property name="futrixweb.bootstrap.file-config.dir" value="E:/SAS/Config/Lev2/Futrix"/>
                            </system-properties>
                        </server>
                        <server name="Futrix9" group="Futrix-Group" auto-start="true">
                            <socket-bindings socket-binding-group="futrix-sockets" port-offset="900"/>
                            <system-properties>
                                <property name="jboss.server.log.dir" value="E:/Logs/Lev9/JBoss/Futrix9"/>
                                <property name="futrixweb.bootstrap.file-config.dir" value="E:/SAS/Config/Lev9/Futrix"/>
                            </system-properties>
                        </server>
                    </servers>
                

                 

                However, that resulted in this error.  Which is self-explanatory, but a bummer.  I would think the host controller process could parse this file and "do the right thing" to pass these properties to spawned server processes?

                 

                [Server:Futrix1] 13:35:47,114 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) Operation ("add") failed - address: ([("system-property" => "jboss.serve
                r.log.dir")]) - failure description: "JBAS015845: System property jboss.server.log.dir cannot be set via the xml configuration file or from a management client; it's value must be
                known at initial process start so it can only set from the commmand line"
                [Server:Futrix1] 13:35:47,117 FATAL [org.jboss.as.server] (Controller Boot Thread) JBAS015957: Server boot has failed in an unrecoverable manner; exiting. See previous messages for
                details.
                

                 

                From my observation of the processes created by my setup:

                 

                • YAJSW is the service wrapper I'm using.  It spawns a java process when the Windows service starts.
                • That process spawns a 2nd java process for the domain controller.
                • The domain controller process (???) spawns a 3rd java process for the host controller.
                • The host controller process (???) spawns the 3 java processes for the defined servers (Futrix1, Futrix2, and Futrix9)

                 

                If the domain controller process reads the domain.xml file, and the host controller process reads the host.xml file (which are conjectures on my part), then the host controller process should be able to pass the jboss.server.log.dir property to the spawned processes.

                 

                Thanks,

                Scott

                • 5. Re: Re: How can I redefine jboss.server.log.dir in domain mode?
                  James Perkins Master

                  Can you specify in which file (eg. domain.xml or host.xml) I would set this, preferably with a bit of context?

                   

                  Also, will the below specify a different server directory for each server?  To me it looks like "E:\Logs\Lev2\JBoss" could be a typo???  It needs to be a different directory path for the three Futrix# servers defined in hosts.xml.

                   

                  ...either add to the HOST_CONTROLLER_JAVA_OPTS in the domain.conf.bat -Djboss.server.log.dir=E:\Logs\Lev2\JBoss.

                   

                  I'll start by saying you should always use the management layer to update the configuration The /host=master:write-attribute(name=directory-grouping,value=by-type) is a CLI command.

                   

                  That said the setting you are looking for is in the host.xml. It's an attribute on the servers tag.

                  <servers directory-grouping="by-type">
                      <server name="server-one" group="main-server-group"/>
                      <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>
                  

                   

                  domain.conf

                  HOST_CONTROLLER_JAVA_OPTS="$HOST_CONTROLLER_JAVA_OPTS -Djboss.server.log.dir=/home/jperkins/tmp/logs/"
                  

                   

                  Assuming the above configuration here is what my directory tree looks like:

                  /home/jperkins/tmp/logs/
                  └── servers
                      ├── server-one
                      │   └── server.log
                      └── server-two
                          └── server.log
                  

                   

                  --

                  James R. Perkins

                  • 6. Re: Re: How can I redefine jboss.server.log.dir in domain mode?
                    Scott Bass Newbie

                    Thanks.  I'm on JBoss 7.1.1 Final.  I'm getting this error:

                     

                    12:28:01,907 INFO  [org.jboss.as.process.Host Controller.status] (main) JBAS012017: Starting process 'Host Controller'

                    [Host Controller] 12:28:02,708 INFO  [org.jboss.modules] (main) JBoss Modules version 1.1.1.GA

                    [Host Controller] 12:28:03,072 INFO  [org.jboss.msc] (main) JBoss MSC version 1.0.2.GA

                    [Host Controller] 12:28:03,251 INFO  [org.jboss.as] (MSC service thread 1-3) JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting

                    [Host Controller] 12:28:03,983 INFO  [org.xnio] (MSC service thread 1-1) XNIO Version 3.0.3.GA

                    [Host Controller] 12:28:03,997 INFO  [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.0.3.GA

                    [Host Controller] 12:28:04,011 INFO  [org.jboss.remoting] (MSC service thread 1-1) JBoss Remoting version 3.2.3.GA

                    [Host Controller] 12:28:06,258 INFO  [org.jboss.as] (Controller Boot Thread) JBAS010902: Creating http management service using network interface (management) port (9990) securePor

                    t (-1)

                    [Host Controller] 12:28:06,445 ERROR [org.jboss.as.host.controller] (Controller Boot Thread) JBAS010907: Failed to start server (Futrix1): java.lang.IllegalArgumentException: No en

                    um constant org.jboss.as.host.controller.DirectoryGrouping.by-type

                     

                    This thread from mid 2012 seems relevant:  https://developer.jboss.org/thread/202466?tstart=0

                     

                    Is there a later version of JBoss (not EAP) where this bug is fixed?

                    • 7. Re: Re: How can I redefine jboss.server.log.dir in domain mode?
                      James Perkins Master

                      Ah yeah. The only way to fix this would be to build an upstream tag of maybe 7.1.2 or higher. You can certainly switch to EAP as well The other option would be to upgrade to WildFly.

                       

                      --

                      James R. Perkins