3 Replies Latest reply on Apr 23, 2011 8:48 AM by maxim rong

    How to config jboss-logging and print Mybaits sql

    maxim rong Newbie

      Hi, i use Mybatis and jboss 6.

      and i want to print sql to the console.

      i try to modify jboss-logging, but it show some error.

      is anyone can show an example for Mybatis or Ibaits log config.

      or give jboss-logging config document.

        • 1. How to config jboss-logging and print Mybaits sql
          jaikiran pai Master

          maxim rong wrote:

           

          i try to modify jboss-logging, but it show some error.

          What changes did you do? And what errors are you running into?

          • 2. Re: How to config jboss-logging and print Mybaits sql
            maxim rong Newbie

            my log4j.xml in my app package is follow:

            {code:xml}

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

            <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

             

            <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

             

                <!-- Console output -->

             

                <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">

                    <layout class="org.apache.log4j.PatternLayout">

                        <param name="ConversionPattern" value="%-5p %d{MM-dd HH:mm:ss} %m  (%F:%L) \n"/>

                    </layout>

                </appender>

             

                <category name="java.sql">

                    <priority value="debug" />

                </category>

                <category name="org.apache.ibatis">

                    <priority value="debug" />

                </category>

                <root>

                    <priority value ="error" />

                    <appender-ref ref="STDOUT" />

                </root>

             

            </log4j:configuration>

            {code}

             

            then the console don't print the sql, so i change jboss-logging.xml in default server like follow:

             

            {code:xml}

            <!-- =============================================== -->

               <!-- Limit categories                                -->

               <!-- if enabling "trace" at root logger level,       -->

               <!-- use limit category settings to disable trace    -->

               <!-- for packages that you don't want to trace       -->

               <!-- =============================================== -->

             

               <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->

               <!-- change org.apache to org.apache.ibatis -->

               <logger category="org.apache.ibatis">

                  <level name="DEBUG"/>

               </logger>

             

               <!-- add java.sql -->

               <logger category="java.sql">

                    <level name="DEBUG"/>

                </logger>

            {code}

             

            and add mybatis jar to sever/lib folder.

            the sql still do not print.

             

            then i change jboss-logging to this :

             

            {code:xml}

            <!-- add a appender -->

            <log4j-appender name="MyBatis" class="org.apache.ibatis">

                    <error-manager>

                     <only-once/>

                  </error-manager>

             

                  <level name="DEBUG"/>

                  <formatter>

                     <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n"/>

                  </formatter>

               </log4j-appender>

            {code}

             

             

            {code:xml}

            <root-logger>

                      <!-- Set the root logger priority via a system property, with a default value. -->

                      <level name="${jboss.server.log.threshold:INFO}"/>

                      <handlers>

                         <handler-ref name="CONSOLE"/>

                         <handler-ref name="FILE"/>

                         <handler-ref name="MyBatis"/>

                      </handlers>

                   </root-logger>

            {code}

             

            then show error is :

            java.lang.ClassNotFoundException: org.apache.ibatis from BaseClassLoader@bf2f7c{vfs:///E:/jboss-6.0.0.Final/server/default/deploy/jboss-logging.xml}

            • 3. Re: How to config jboss-logging and print Mybaits sql
              maxim rong Newbie

              now i have change my jboss-logging.xml like follow:

               

              {code:xml}

              <log4j-appender name="LOG4JCONSOLE" class="org.apache.log4j.ConsoleAppender">

                    <error-manager>

                       <only-once/>

                    </error-manager>

                    <level name="DEBUG"/>

                    <formatter>

                       <pattern-formatter pattern="%-5p %d{MM-dd HH:mm:ss} %m  (%F:%L) \n"/>

                    </formatter>

                 </log4j-appender>

               

               

              <!-- ======================= -->

                 <!-- Setup the Root category -->

                 <!-- ======================= -->

               

                     <root-logger>

                        <!-- Set the root logger priority via a system property, with a default value. -->

                        <level name="${jboss.server.log.threshold:INFO}"/>

                        <handlers>

                           <handler-ref name="CONSOLE"/>

                           <handler-ref name="FILE"/>

                           <handler-ref name="LOG4JCONSOLE"/>

                        </handlers>

                     </root-logger>

              {code}

               

              i seems Infinite loop to print log....