8 Replies Latest reply on Mar 26, 2009 5:02 AM by Rasa Here

    logging in jboss

    Rasa Here Novice

      hi,

      In my application i am using jboss 3.2.5 and i am using log4j for getting my application module wise log. I have another log named as consolelog and its configured as follows.

      "$JAVA" $JAVA_OPTS -XX:OnError="kill -3 %p;gdb -command=cmd - %p" \
       -classpath "$JBOSS_CLASSPATH" \
       org.jboss.Main "$@" > /usr/jboss/logs/consolelog.log 2>&1
      


      But the size of this increases and hence an it becomes 1 gb with in a few days. Its difficult to open the file using vi. So i need to configure this in log4j with daily rolling appender function. But i don't know how to do it.

      I did my log4j configuration in default/conf/log4j.xml as follows.

      <category name="org.jboss.Main">
       <priority value="INFO" />
       <appender-ref ref="console" />
       </category>
      
      
       <appender name="console"
       class="org.jboss.logging.appender.DailyRollingFileAppender">
       <errorHandler
       class="org.jboss.logging.util.OnlyOnceErrorHandler" />
       <param name="File"
       value="/usr1/jboss-3.2.5/server/default/log/consolelog.log" />
       <param name="Append" value="false" />
       <param name="Threshold" value="INFO" />
      
      
       <!-- Rollover at midnight each day -->
       <param name="DatePattern" value="'.'yyyy-MM-dd" />
      
       <!-- Rollover at the top of each hour
       <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
       -->
      
       <layout class="org.apache.log4j.PatternLayout">
       <!-- The default pattern: Date Priority [Category] Message\n -->
       <param name="ConversionPattern" value="%d %-5p [%c] %m%n" />
      
       <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
       <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
       -->
       </layout>
       </appender>
      
      

      but its not working. Please guide me to find a solution.

      Thanks and Regards
      Rasa


        • 1. Re: logging in jboss
          Peter Johnson Master

          By "not working" do you mean that you are not getting a log file, or that the log file is not rolling over each day?

          The default console appender is named CONSOLE, why didn't you just change that appender to use the rolling file appender? Based on what you have, only the orj.jboss.Main class will log anything to your appender.

          • 2. Re: logging in jboss
            Rasa Here Novice

            Yes its working fine. I got it from the log4j and jboss docs.

            But is there any option to do the same through the command given below.

            "$JAVA" $JAVA_OPTS -XX:OnError="kill -3 %p;gdb -command=cmd - %p" \
             -classpath "$JBOSS_CLASSPATH" \
             org.jboss.Main "$@" > /usr/jboss/logs/consolelog.log 2>&1
            


            In the above case how can i add Rolling appender facility. Can i specify the maximum file size and once its reached the peak then name it as log.1 and then contiue with the other.

            Thanks and Regards
            Rasa





            • 3. Re: logging in jboss
              Peter Johnson Master

              What you are asking for is a "rolling console appender" - there is no such thing. If you want the logging statements that currently go to the console to instead be placed into a rolling file, you must switch the CONSOLE appender to use the RollingFileAppender.

              • 4. Re: logging in jboss
                Rasa Here Novice

                I have configured it as

                <appender name="CONSOLE"
                 class="org.jboss.logging.appender.DailyRollingFileAppender">
                 <errorHandler
                 class="org.jboss.logging.util.OnlyOnceErrorHandler" />
                 <param name="File"
                 value="${jboss.server.home.dir}/log/console.log" />
                 <param name="Append" value="true" />
                 <param name="Threshold" value="INFO" />
                
                
                 <!-- Rollover at midnight each day -->
                 <param name="DatePattern" value="'.'yyyy-MM-dd" />
                
                 <!-- Rollover at the top of each hour
                 <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
                 -->
                
                 <layout class="org.apache.log4j.PatternLayout">
                 <!-- The default pattern: Date Priority [Category] Message\n -->
                 <param name="ConversionPattern" value="%d %-5p [%c] %m%n" />
                
                 <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
                 <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
                 -->
                 </layout>
                 </appender>
                


                And its working fine. But now one issue i am facing in the earlier case when i gives kill -3 processid then i used to get the Threaddump in my console.,But after this change i am not getting that. Anything wrong in my configuration or anything more i need to add in that. Please suggest a method.

                Thanks and Regards
                Rasa

                • 5. Re: logging in jboss
                  Peter Johnson Master

                  Thread dumps do not go to the log file because the internal JVM code does the dump, it is not handled by any Java code. If you want thread dumps to show up in a file you will still need to redirect stdout/stderr to a file.

                  • 6. Re: logging in jboss
                    Rasa Here Novice

                    But the CONSOLE gets stdout only rt? , so why its not printing it. I have checked the log4j.xml in run.jar

                    <param name="Target" value="System.out"/>
                    

                    so i think it should print all the System.out stuffs rt ? , So any way jvm prints threaddump in stdout.
                    Please provide more idea about it.

                    Thanks and Regards
                    Rasa

                    • 7. Re: logging in jboss
                      Peter Johnson Master

                       

                      But the CONSOLE gets stdout only rt?


                      Yes and no. Any Java code that writes to System.out will go to the logs. But as I said in my previous reply, the thread dump is written by the JVM (that is, it is done internally using C/C++ code). Therefore thread dumps will never appears in the logs. Note that when you generate a thread dump that the output does not use the logs conversion pattern - that is, no leading timestamp and such.

                      • 8. Re: logging in jboss
                        Rasa Here Novice

                        thanks peter, thanks for your kind attention.

                        So in that case i will have to go back to my previous configuration. But that case is also have one issue and the same i mentioned above. It is nothing but log size issue.

                        Thanks for your guidance
                        Rasa