1 Reply Latest reply on Sep 20, 2019 5:24 AM by Vladimir Zhuravlevich

    Can you configure WAR logging without editing the standalone.xml?

    Matt Reinker Newbie

      I am serving a WAR file in a Standalone instance of JBOSS eap 7.2.   The WAR file is set to log to two different log files; application.log and request.log.

       

      The WAR deploys as expected and appears to be working, but the log files are ignored.  They get created, but nothing gets written to them.

      I am seeing some INFO entries getting written to the JBOSS server.log, but nothing in my logs.

       

      I have discovered that I can edit standalone.xml and add loggers there, allowing me output the logs to a log file and change the logging level, though I haven't figured out how to get it to sort the two log entries to different logs.

      But in the Production deployment of the WAR, I'm not sure I'll have access to standalone.xml to make the necessary changes.

       

      Are there any changes I can make to the WARs log4j2.xml file to allow it to write to my log files, without making any changes to standalone.xml? 

       

      Here is a copy of the log4j2.xml file I am using.

       

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

      <Configuration monitorInterval="30">

          <Properties>

              <Property name="baseDir">/opt/jboss-eap-7.2/standalone/log</Property>

          </Properties>

       

          <Appenders>

              <Console name="STDOUT" target="SYSTEM_OUT">

                  <PatternLayout pattern="%d: [%-5p] %c{1} - %m%n"/>

              </Console>

              <Console name="STDERR" target="SYSTEM_ERR">

                  <PatternLayout pattern="%d: [%-5p] %c{1} - %m%n"/>

              </Console>

              <Async name="asyncManager" blocking="false" bufferSize="1024">

                  <AppenderRef ref="logFile"/>

              </Async>

       

              <RollingFile name="logFile"

                           fileName="${baseDir}/application.log"

                           filePattern="${baseDir}/application.log.%d{yyyy-MM-dd}.gz">

                  <PatternLayout pattern="%d: [%-5p] %c{1} - %m%n"/>

                  <Policies>

                      <TimeBasedTriggeringPolicy interval="1" modulate="true"/>

                  </Policies>

                  <DefaultRolloverStrategy compressionLevel="9"/>

              </RollingFile>

       

              <RollingFile name="RequestLogRollingFileAppender"

                           fileName="${baseDir}/request.log"

                           filePattern="${baseDir}/request.log.%i.gz">

                  <PatternLayout pattern="%d{yyyy-MM-dd'T'HH:mm:ss.SSSZZ}: [%p] %t %c - %m%n"/>

                  <Policies>

                      <SizeBasedTriggeringPolicy size="1000 KB"/>

                  </Policies>

                  <DefaultRolloverStrategy max="10" compressionLevel="9"/>

              </RollingFile>

          </Appenders>

          <Loggers>

              <Logger name="request.output" additivity="true" level="info">

                  <AppenderRef ref="RequestLogRollingFileAppender"/>

              </Logger>

       

              <Root level="warn">

                  <AppenderRef ref="asyncManager"/>

              </Root>

          </Loggers>

      </Configuration>