0 Replies Latest reply on Sep 12, 2018 3:17 PM by Paul Londino

    How to share configuration between logging-profiles

    Paul Londino Newbie

      I have set up per-deployment application logging in WildFly 8.2.0 following the documentation. I have several applications deployed to the same WildFly instance and I just want to split out the logs for each application to a separate log file.  However, it seems I have to specify the entire log configuration for every application, so it winds up being VERY verbose. Additionally, it requires a fair amount of repetition (e.g. having to specify the pattern in multiple places).  Really I just want to override the filename of the log for each app. Is there a way to define a single logging-profile and then use a property from a deployment to set the filename?

       

      Is there any way to share the configuration between log profiles or between a log profile and the main logger?  Also, is there any problem with having both the main logger and logging profiles all writing to the console?

       

      <subsystem xmlns="urn:jboss:domain:logging:2.0">
          <console-handler name="CONSOLE">
              <level name="INFO"/>
              <formatter>
                  <named-formatter name="PATTERN"/>
              </formatter>
          </console-handler>
          <periodic-rotating-file-handler name="FILE" autoflush="true">
              <formatter>
                  <named-formatter name="PATTERN"/>
              </formatter>
              <file relative-to="jboss.server.log.dir" path="server.log"/>
              <suffix value=".yyyy-MM-dd"/>
              <append value="true"/>
          </periodic-rotating-file-handler>
          <root-logger>
              <level name="INFO"/>
              <handlers>
                  <handler name="CONSOLE"/>
                  <handler name="FILE"/>
              </handlers>
          </root-logger>
          <formatter name="PATTERN">
              <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
          </formatter>
          <logging-profiles>
              <logging-profile name="app1">
                  <formatter name="PATTERN">
                      <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                  </formatter>
                  <console-handler name="CONSOLE">
                      <level name="INFO"/>
                      <formatter>
                          <named-formatter name="PATTERN"/>
                      </formatter>
                  </console-handler>              
                  <size-rotating-file-handler name="FILE" autoflush="true">
                      <level name="INFO"/>
                      <formatter>
                          <named-formatter name="PATTERN"/>
                      </formatter>                        
                      <file relative-to="jboss.server.log.dir" path="app1.log"/>
                      <append value="true"/>
                  </size-rotating-file-handler>
                  <root-logger>
                      <level name="INFO"/>
                      <handlers>
                          <handler name="FILE"/>
                      </handlers>
                  </root-logger>
              </logging-profile>
              <logging-profile name="app2">
                  <formatter name="PATTERN">
                      <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                  </formatter>
                  <console-handler name="CONSOLE">
                      <level name="INFO"/>
                      <formatter>
                          <named-formatter name="PATTERN"/>
                      </formatter>
                  </console-handler>              
                  <size-rotating-file-handler name="FILE" autoflush="true">
                      <level name="INFO"/>
                      <formatter>
                          <named-formatter name="PATTERN"/>
                      </formatter>                        
                      <file relative-to="jboss.server.log.dir" path="app2.log"/>
                      <append value="true"/>
                  </size-rotating-file-handler>
                  <root-logger>
                      <level name="INFO"/>
                      <handlers>
                          <handler name="CONSOLE"/>
                          <handler name="FILE"/>
                      </handlers>
                  </root-logger>
              </logging-profile>
          </logging-profiles>
      </subsystem>