1 Reply Latest reply on Jul 21, 2016 12:48 PM by James Perkins

    Migrating from tomcat 7 to Jboss EAP 6.4.0 application log not generated

    sunil k Newbie

      Hi,

       

      In our application we are using slf4j1.7.12 and log4j-1.2.17. Our log4j configuration file (log4j.xml ) outside of .war file. We created a module for log4j1.2.17.jar. Added jboss-deployment-structure.xml file to WEN-INF directory. Still there is no data in application logs . Please help.

       

       

      Configuration:

      c:\jboss\EAP-6.4.0\bin\standalone.conf.bat

      set "JAVA_OPTS=%JAVA_OPTS% -Dappname.log4jConfig=file:///c:\appname\logs\conf\log4j.xml"

       

      c:\jboss\EAP-6.4.0\modules\compname\org\log4j\mainmodule.xml.

       

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

      <module xmlns="urn:jboss:module:1.0" name="compname.org.log4j">

          <resources>

              <resource-root path="log4j-1.2.17.jar"/>

          </resources>

          <dependencies>

              <module name="javax.api"/>

          </dependencies>

      </module>

       

      jboss-deployment-structure.xml


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

      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">

          <deployment>

           <dependencies>

                  <module name="compname.org.log4j" slot="main" />

           </dependencies>

              <exclusions>

                  <module name="org.apache.log4j" />

              </exclusions>

          </deployment>

      </jboss-deployment-structure>

       

      log4j.xml

       

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

      <Configuration monitorInterval="1">

        <!-- Appenders -->

        <Appenders>

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

            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} | %-5p | %X{requestUri} | %c:%L - %m%n" />

          </Console>

          <!-- appname Log Appenders -->

          <RollingFile name="FILE_ALL" fileName="${sys:appname.base}/logs/appname/appname.log" filePattern="${sys:appname.base}/logs/appname/appname.%d{yyyy-MM-dd}-%i.log">

            <PatternLayout>

              <pattern>%d{yyyy-MM-dd HH:mm:ss,SSS} | %-5p | %X{requestUri} | %c:%L - %m%n</pattern>

            </PatternLayout>

            <Policies>

              <OnStartupTriggeringPolicy />

              <TimeBasedTriggeringPolicy />

              <SizeBasedTriggeringPolicy size="50 MB" />

            </Policies>

            <DefaultRolloverStrategy max="10" />

          </RollingFile>

          <RollingFile name="FILE_JOB" fileName="${sys:appname.base}/logs/appname/job.log" filePattern="${sys:appname.base}/logs/appname/job.%d{yyyy-MM-dd}-%i.log">

            <PatternLayout>

              <pattern>%d{yyyy-MM-dd HH:mm:ss} | %-5p | %X{requestUri} | %c:%L - %m%n</pattern>

            </PatternLayout>

            <Policies>

              <OnStartupTriggeringPolicy />

              <TimeBasedTriggeringPolicy />

              <SizeBasedTriggeringPolicy size="50 MB" />

            </Policies>

            <DefaultRolloverStrategy max="10" />

          </RollingFile>

          <!-- /appname Log Appenders -->

        </Appenders>

       

       

        <Loggers>

          <!-- Apache Logger -->

        <Logger name="org.apache.struts2" level="debug" additivity="false">

            <AppenderRef ref="FILE_ALL" />

          </Logger>

          <Logger name="org.apache" level="error" additivity="false">

            <AppenderRef ref="FILE_ALL" />

          </Logger>

          <!-- /Apache Logger -->

          <!-- Hibernate Logger -->

          <Logger name="org.hibernate" level="info" additivity="false">

            <AppenderRef ref="FILE_ALL" />

          </Logger>

          <!-- /Hibernate Logger -->

          <!-- EhCache Logger -->

          <Logger name="net.sf.ehcache" level="info" additivity="false">

            <AppenderRef ref="FILE_ALL" />

          </Logger>

          <!-- /EhCache Logger -->

          <!-- Spring Logger -->

          <Logger name="org.springframework" level="info" additivity="false">

            <AppenderRef ref="FILE_ALL" />

          </Logger>

          <Logger name="org.springframework.security" level="info" additivity="false">

            <AppenderRef ref="FILE_ALL" />

          </Logger>

          <!-- /Spring Logger -->

          <!-- End of Day Logger -->

          <Logger name="com.compname.module.eod.daterelatednotification" level="info" additivity="false">

            <AppenderRef ref="FILE_EOD" />

          </Logger>

          <!-- /End of Day Logger -->

          <Logger name="org.apache.log4j.xml" level="info" />

        </Loggers>

      </Configuration>

       

       

      At the time of starting server it is showing

       

      10:17:37,322 DEBUG [org.jboss.as.config] (MSC service thread 1-6) Configured system properties:

      appname.log4jConfig=file:///c:\appname\logs\conf\log4j.xml



        • 1. Re: Migrating from tomcat 7 to Jboss EAP 6.4.0 application log not generated
          James Perkins Master

          Since slf4j does static binding for it's implementation you'll need to do 3 things. (Note you might be able to just exclude the org.slf4j and org.apache.log4j modules, but if you're not using the logging subsystem features it will just be easier to exclude the subsystem)

          1. Exclude the logging subsystem in your jboss-deployment-structure.xml
          2. Include the slf4j API in your deployment
          3. Include the slf4j binding in your deployment or as you are doing now include a slf4j binding module.

           

          Your other option would be to use the logging subsystem for the configuration. If you want a different configuration for each deployment you could use logging-profiles which would allow you to make runtime changes to logging rather than having to redeploy each time you need to change the logging configuration.

           

          --

          James R. Perkins