8 Replies Latest reply on Oct 24, 2008 12:02 PM by Peter Johnson

    Jboss server.log to syslog redirection

    raja murugan Newbie

      Hi all,

      Can any one please tell me the how to redirect the server.log message to syslog (var/log/messages) in Jboss 4.3.0 application Server.


      Thanks .

      Regards,
      Raja K

        • 1. Re: Jboss server.log to syslog redirection
          erasmo2 marciano2 Master

          You have to edit the conf/log4j.xml and modify this line code

           <!-- A time/date based rolling appender -->
           <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
           <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
           <param name="File" value="${jboss.server.log.dir}/server.log"/>
           <param name="Append" value="false"/>
          


          Why do you redirect it into /var/log/messages

          • 2. Re: Jboss server.log to syslog redirection
            Peter Johnson Master

            JBossAS uses log4j to do its logging. erasmomarciano pointed you to the correct lines in the log configuration file (which, by the way, is at server/xxx/conf/jboss-log4j.xml), but highlighted the wrong line. Log4j has a syslog appender that you can use. Change the appender class as follows:

            <!-- Updated to use the syslog appender -->
            <appender name="FILE" class="org.apache.log4j.net.SyslogAppender">
             ...


            • 3. Re: Jboss server.log to syslog redirection
              raja murugan Newbie

              Thank you very much for your reply.

              Here my jboss-log4j.xml file

              <!-- ================================= -->
              <!-- Preserve messages in a local file -->
              <!-- ================================= -->

              <!-- A time/date based rolling appender -->






              i uncommented the syslog events,

              <!-- Syslog events -->











              Then,i did the entry into the file /etc/syslog.conf

              local7.* /var/log/jboss.log

              restarted the syslog service.The jboss.log file is created.But when i start the Jboss server log message isn't going my jboss.log file.It's going the same server.log file.If i comment the following the line.

              <!-- A time/date based rolling appender



              -->


              the logs is disappear from the file(i.e not writing the logs in to server.log or jboss.log file)

              My aim is we have the central Syslog server.i have to forward jboss server.log into central syslog server.

              Can you please direct me how to do.

              Thanks

              Regards,
              Raja K

              • 4. Re: Jboss server.log to syslog redirection
                raja murugan Newbie


                <!-- A time/date based rolling appender




                -->
                
                Syslog Event
                
                
                 <!-- Syslog events -->
                 <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
                 <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                 <param name="Facility" value="LOCAL7"/>
                 <param name="FacilityPrinting" value="true"/>
                 <param name="SyslogHost" value="localhost"/>
                 <layout class="org.apache.log4j.PatternLayout">
                 <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
                 </layout>
                 </appender>
                
                
                


                • 5. Re: Jboss server.log to syslog redirection
                  raja murugan Newbie

                  i am using Red Hat Enterprise Linux 5.



                  • 6. Re: Jboss server.log to syslog redirection
                    Peter Johnson Master

                    You also need to indicate what log statements you want to go to the appender. In jboss-log4j.xml, all logging goes to both the CONSOLE and FILE appenders based on this statement:

                    <root>
                     <appender-ref ref="CONSOLE"/>
                     <appender-ref ref="FILE"/>
                     </root>


                    To log everything to syslog, add another line here.

                    By the way, you will get a lot of logging, including debug and trace log entries. Are you sure you don't want to limit the syslog to WARN or ERROR?

                    • 7. Re: Jboss server.log to syslog redirection
                      raja murugan Newbie

                      Peter,

                      Thanks for your help, I am unable to get the jboss log redirected to SYSLOG. Could you please give me hints on how to debug and get it working.

                      • 8. Re: Jboss server.log to syslog redirection
                        Peter Johnson Master

                        Well, now you are outside of JBossAS territory and into Log4j territory. So I would get the source code for log4j and start going through it. My first task would be to write a simple Java app and get it to log to syslog, using an xml config file. If that did not help, or I could not get that to work, I would use a debugger to determine what is going on in log4j.