2 Replies Latest reply on Aug 28, 2014 11:05 PM by anandpaul

    How to create a custom/application logging file in jboss-as-7.1.1.Final?

    anandpaul

      Hi All,

       

      I am very new to jBoss world and so trying to figure out on how to configure the application specific logging in jBoss 7.1.1. After the logging is not working and after googling, I found out that we need to create a separate class loading for the application so that jBoss will not disturb the application specific logging and then I made the following changes. Even then, the logging is not working. I followed the suggestions provided by jaikiran.jai_forums2005.yahoo.co.in

       

      Added a new file called jboss-web.xml in META-INF folder in the path WebContent\META-INF\jboss-web.xml. Entry of the file is:

       

      <jboss-web>
        <class-loading java2ClassLoadingCompliance="false">
        <loader-repository>
        com.actions:loader=MyClassLoader
        <loader-repository-config>
        java2ParentDelegation=false
        </loader-repository-config>
        </loader-repository>
        </class-loading>
      </jboss-web> 
      

       

      Log4j.properties in the path \src\log4j.properties

       

      # Set root logger level to WARN and append to stdout
      log4j.rootLogger=DEBUG, file
      log4j.appender.file.File=C:\\Temp\\logigng.log
      log4j.appender.file.MaxFileSize=10MB
      log4j.appender.file.MaxBackupIndex=10
      log4j.appender.file.layout=org.apache.log4j.PatternLayout
      
      
      # Direct log messages to a log file
      log4j.appender.file=org.apache.log4j.RollingFileAppender
      
      
      # Pattern to output the caller's file name and line number.
      log4j.appender.file.layout.ConversionPattern=%d %5p (%c:%L) - %m%n
      
      
      # Print only messages of level ERROR or above in the package noModule.
      log4j.logger.noModule=DEBUG
      
      
      #log4j.logger.com.opensymphony.xwork2=DEBUG
      #log4j.logger.org.apache.struts2=DEBUG
      log4j.logger.com.actions=DEBUG
      

       

      I made sure that the Log4j and jboss-web.xml files are in the classpath so that they are picked up during the application execution. FYI, the logging is working in a standalone file and so I confirm that the log4j properties are correct.

       

      Please let me know on how to fix this issue..

      Thanks in advance...

       

      ---Anand

        • 1. Re: How to create a custom/application logging file in jboss-as-7.1.1.Final?
          jamezp

          With JBoss AS 7.x you'd need to do something like How To - JBoss AS 7.1.


          --

          James R. Perkins

          1 of 1 people found this helpful
          • 2. Re: Re: How to create a custom/application logging file in jboss-as-7.1.1.Final?
            anandpaul

            Hi James,

             

            Thanks for your reply.

             

            I created a file jboss-deployment-structure.xml and I get the following error while deployment. The XML file was giving me the validation error and then I corrected the URN version from 1.2 to 2.0. The validation error is gone, but end up with deployment error that unexpected element URN....

             

            Then I removed the xmlns and tested. It worked.  Thanks for your help!!!

             

            <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:2.0">
                <deployment>
                    <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
                    <exclusions>
                        <module name="org.apache.log4j" />
                    </exclusions>
                </deployment>
            </jboss-deployment-structure>
            

             

             

            12:39:02,686 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015877: Stopped deployment PPCSE_v1.war in 0ms
            12:39:02,690 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015876: Starting deployment of "PPCSE_v1.war"
            12:39:02,690 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015863: Replacement of deployment "PPCSE_v1.war" by deployment "PPCSE_v1.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"PPCSE_v1.war\".STRUCTURE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"PPCSE_v1.war\".STRUCTURE: Failed to process phase STRUCTURE of deployment \"PPCSE_v1.war\""}}
            12:39:06,851 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.unit."PPCSE_v1.war".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."PPCSE_v1.war".STRUCTURE: Failed to process phase STRUCTURE of deployment "PPCSE_v1.war"
              at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_67]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_67]
              at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_67]
            Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Error loading jboss-structure.xml from C:\Software\jboss-as-7.1.1.Final\standalone\tmp\vfs\temp21ef9e805145214b\PPCSE_v1.war-c466ea3ae2c96c58\WEB-INF\jboss-deployment-structure.xml
              at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:277) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:249) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.deploy(DeploymentStructureDescriptorParser.java:134) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
              ... 5 more
            Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,1]
            Message: Unexpected element '{urn:jboss:deployment-structure:2.0}jboss-deployment-structure'
              at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:108) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
              at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
              at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:271) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
              ... 8 more