6 Replies Latest reply on Jul 16, 2013 3:22 AM by sfcoy

    jboss log info twice

    gaoyonglu

      I  use jboss 7.2.final ,the logger will info twice:

      16:54:51,765 INFO  [stdout] (web-container-thread-3) 2013-07-15 16:54:51,765 [web-container-thread-3] INFO  com.unionpay.TT.Test - get get..

      16:54:51,765 INFO  [com.unionpay.TT.Test] (web-container-thread-3) get get..

       

      I think “ INFO  [stdout] (web-container-thread-3) 2013-07-15 16:54:51,765 [web-container-thread-3] INFO  com.unionpay.TT.Test - get get......................... "is the same with below.

      and "[com.unionpay.TT.Test] (web-container-thread-3) get get.." use my ConversionPattern

       

      log4j:

      log4j.rootLogger=INFO

      log4j.logger.com.unionpay=DEBUG,CONSOLE

      log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender

      log4j.appender.CONSOLE.Threshold=DEBUG

      log4j.appender.CONSOLE.Target=System.out

      log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout

      log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

       

       

      I only want once logger info。

        • 1. Re: jboss log info twice
          rhusar

          Seem like you are bundling log4j, which prints out to console (System.out) which is then caught by AS logger and it wraps the message again and really prints it out.

           

          I would recommend just sticking with what is bundled in the AS, have a provided dependency on JBoss logging jar.

          1 of 1 people found this helpful
          • 2. Re: jboss log info twice
            gaoyonglu

            I want my ear use log4j and log ConversionPattern use ours。

             

            do you know how AS logger don't  wraps the message.

            • 3. Re: jboss log info twice
              sfcoy

              You can still use the log4j API and your own conversion pattern.

               

              Leave the log4j jar (and it's configuration file) out of your deployment (JBossAS will provide an implementation for you) and then change existing JBoss log handlers or add your own as needed. Have a look at the logging subsystem configuration in standalone.xml.

               

              This has the advantage that you can adjust logging configuration while your application is running, which is tricky to do with an embedded properties files based configuration.

              • 4. Re: jboss log info twice
                gaoyonglu

                my standalone.xml:

                subsystem xmlns="urn:jboss:domain:logging:1.2">

                            <periodic-rotating-file-handler name="FILE" autoflush="true">

                                <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>

                            <size-rotating-file-handler name="SIZE_ROTATE_FILE" autoflush="true">

                                <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"/>

                                <rotate-size value="100M"/>

                                <max-backup-index value="8"/>

                                <append value="true"/>

                            </size-rotating-file-handler>

                            <logger category="com.arjuna">

                                <level name="WARN"/>

                            </logger>

                            <logger category="org.apache.tomcat.util.modeler">

                                <level name="WARN"/>

                            </logger>

                            <logger category="org.jboss.as.config">

                                <level name="DEBUG"/>

                            </logger>

                            <logger category="sun.rmi">

                                <level name="WARN"/>

                            </logger>

                            <logger category="jacorb">

                                <level name="WARN"/>

                            </logger>

                            <logger category="jacorb.config">

                                <level name="ERROR"/>

                            </logger>

                            <root-logger>

                                <level name="INFO"/>

                                <handlers>

                                    <handler name="SIZE_ROTATE_FILE"/>

                                </handlers>

                            </root-logger>

                        </subsystem>

                 

                 

                I want use log4j and log4j properties like jboss 5  and jboss logger don't warp my log4j console log

                • 5. Re: jboss log info twice
                  sfcoy

                  If you really want to stick with your own log4j.properties file then you will need to create a jboss-deployment-structure.xml file as described in https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+AS7 and use it to exclude the logging subsystem from your application.

                  • 6. Re: jboss log info twice
                    sfcoy

                    I think something like:

                    {code:xml}<jboss-deployment-structure>

                         <deployment>

                              <exclusions>

                                   <module name="org.jboss.logmanager" />

                              </exclusions>

                         </deployment>

                    </jboss-deployment-structure>{code}

                    could work. I have not tried it though.