5 Replies Latest reply on Mar 26, 2009 6:12 PM by neiluku

    JDBCAppender not logging stacktrace

      I am trying to log errors in DB(MS Sql Server) using JDBCAppender.
      The debug and info messages are logged in db, but not the trace. please help..using File Appender and Console appender, the trace is logging correctly.

        • 1. Re: JDBCAppender not logging stacktrace

           

          "neiluku" wrote:
          I am trying to log errors in DB(MS Sql Server) using JDBCAppender.
          The debug and info messages are logged in db, but not the trace. please help..using File Appender and Console appender, the trace is logging correctly.

          <appender name="jdbcAppender" class="org.apache.log4j.jdbc.JDBCAppender">
          <param name="Threshold" value="ERROR"/>
          <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="INSERT INTO log(log_date, log_level, location, message) VALUES ( '%d{MM/dd/yyyy HH:mm:ss}', '%-5p', '%C;%L', '%m' )"/>
          </layout>
          </appender>


          • 2. Re: JDBCAppender not logging stacktrace
            peterj

            Are you sure you want to log trace messages to the database? But then, I wouldn't want to log debug messages there either.

            Anyway, there are two requirements to log messages at a given level (such as TRACE) to an appender:

            1) The appender must allow log entries at that level (look at the Threshold setting).

            2) The category priority for the loggers must enable that level. In other words, setting level to DEBUG will prevent trace messages from being logged.

            • 3. Re: JDBCAppender not logging stacktrace

              I want to log only the error in to the db. if I have the code as
              logger.error("object is null " + e.getMessage() , e);

              This log only the first part including e.getMessage() but not the Throwable.

              below is my jdbc appender setting.



              <param name="ConversionPattern" value="INSERT INTO log(log_date, log_level, location, message) VALUES ( '%d{MM/dd/yyyy HH:mm:ss}', '%-5p', '%C;%L', '%m' )"/>

              • 4. Re: JDBCAppender not logging stacktrace
                peterj

                Your conversion pattern does not include the throwable. Actually, I don't know of any pattern letter that will get you the throwable.

                • 5. Re: JDBCAppender not logging stacktrace

                  Thank you for your input. '%m' logs the stacktrace to the console and to teh file, but not to db. I have downloaded jdbcappender.jar from http://www.dankomannhaupt.de/projects/jdbcappender/doc/org/apache/log4j/jdbcplus/JDBCAppender.html and I can log throwable to db now.