logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vaibhav Kumar" <vaibhavkuma...@gmail.com>
Subject Re: CLOB column datatype for JDBCPlus jdbc appender
Date Mon, 01 Dec 2008 10:37:53 GMT
Hi Ece,
For CLOB usage, you would have to modify log4j.xml by using the prepared
statement approach. Also you would have to use MDC in your logger class.
eg. in log4j.xml

<appender name="JDBC" class="org.apache.log4j.jdbcplus.JDBCAppender">

        <param name="url" value="jdbc:oracle:thin:@localhost:1521:XE"/>
         <param name="dbclass" value="oracle.jdbc.OracleDriver" />
        <param name="username" value="system" />
        <param name="password" value="welcome1" />
        <param name="connector"
value="edu.unc.its.util.MyOracleConnectionHandler" />
        <param name="table" value="error_log" />
          <param name="column" value="id~ORACLE_SEQUENCE~error_log_seq" />
         <param name="column" value="process_id~MDC~ProcessId" />
         <param name="column" value="process_name~MDC~ProcessName" />
         <param name="column" value="message_id~MDC~MessageId" />
         <param name="column" value="transaction_id~MDC~TransactionId" />
         <param name="column" value="instance_id~MDC~InstanceId" />
         <param name="column" value="source_system~MDC~SourceSystem" />
         <param name="column" value="target_system~MDC~TargetSystem" />
         <param name="column" value="error_log_level~MDC~ErrorLogLevel"
/>
         <param name="column" value="attribute1~MDC~Attribute1" />
         <param name="column" value="attribute2~MDC~Attribute2" />
         <param name="column" value="attribute3~MDC~Attribute3" />
         <param name="column" value="attribute4~MDC~Attribute4" />
         <param name="column" value="attribute5~MDC~Attribute5" />
         <param name="column" value="error_message~MDC~ErrorMessage" />
         <param name="column" value="row_mod_dt~MDC~RowModifyDate" />
         <param name="column" value="row_create_dt~MDC~RowCreateDate" />
         <param name="column" value="message_timestamp~MDC~MessageTimestamp"
/>
          <param name="usePreparedStatements" value="true" />
          <param name="usePreparedStatements" value="true" />
         <filter class="org.apache.log4j.varia.LevelRangeFilter">
            <param name="LevelMin" value="error" />
            <param name="LevelMax" value="fatal" />
        </filter>
    </appender>

In logger class code snippet can be:
        MDC.put(MESSAGE_TIMESTAMP, getMessageDate(date_time));
        MDC.put(PROCESS_ID, process_id);
        MDC.put(PROCESS_NAME, process_name);
        MDC.put(MESSAGE_ID, message_id);
        MDC.put(TRANSACTION_ID, transaction_id);
        MDC.put(INSTANCE_ID, instance_id);
        MDC.put(SOURCE_SYSTEM, source);
        MDC.put(TARGET_SYSTEM, target);
        MDC.put(ERROR_LOG_LEVEL, service_level);
        MDC.put(ERROR_MESSAGE, message);
        MDC.put(ROW_MODIFY_DATE, formatter.format(new Date()));
        MDC.put(ROW_CREATE_DATE, formatter.format(new Date()));

subsequently removal also:

        MDC.remove(PROCESS_ID);
        MDC.remove(PROCESS_NAME);
        MDC.remove(MESSAGE_TIMESTAMP);
        MDC.remove(MESSAGE_ID);
        MDC.remove(TRANSACTION_ID);
        MDC.remove(INSTANCE_ID);
        MDC.remove(SOURCE_SYSTEM);
        MDC.remove(TARGET_SYSTEM);
        MDC.remove(ERROR_LOG_LEVEL);
        MDC.remove(ERROR_MESSAGE);
        MDC.remove(ROW_MODIFY_DATE);
        MDC.remove(ROW_CREATE_DATE);


Thanks & Regards,
Vaibhav


On Tue, Nov 25, 2008 at 8:34 PM, Ece Yildirim <eceyld@yahoo.com> wrote:

>
> Hi Vaibhav,
>
> I am suffering of the same error. Could you find a solution regarding this
> problem ? I checked org.apache.log4j.jdbcplus.JDBCLogger class, there seems
> to be no explicit implementation for CLOB data type.
>
> Thank you
> Ece
>
>
>
>
> Vaibhav Kumar wrote:
> >
> > Hi,
> > I am using JDBCPlus (http://www.dankomannhaupt.de/projects/index.html )
> as
> > a
> > jdbc appender for my application. For a particular requirement, I have to
> > make a column datatype from varchar2(4000) to CLOB. But as soon as I do
> > this, my application fails to log in database giving stack trace as
> >
> > log4j:ERROR JDBCAppender::flush_buffer(), :
> > java.sql.SQLException: Internal Error: Unable to construct a Datum from
> > the
> > specified input
> >    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
> >    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
> >    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:829)
> >    at oracle.sql.SQLUtil.makeDatum(SQLUtil.java:645)
> >    at oracle.sql.SQLUtil.makeOracleDatum(SQLUtil.java:946)
> >    at
> >
> oracle.jdbc.driver.UpdatableResultSet.updateObject(UpdatableResultSet.java:1568)
> >    at
> >
> oracle.jdbc.driver.OracleResultSet.updateObject(OracleResultSet.java:2787)
> >    at org.apache.log4j.jdbcplus.JDBCLogger.append(JDBCLogger.java:742)
> >    at
> >
> org.apache.log4j.jdbcplus.JDBCAppender.flush_buffer(JDBCAppender.java:887)
> >    at
> org.apache.log4j.jdbcplus.JDBCAppender.append(JDBCAppender.java:867)
> >    at
> > org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
> >    at
> >
> org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:65)
> >    at org.apache.log4j.Category.callAppenders(Category.java:203)
> >    at org.apache.log4j.Category.forcedLog(Category.java:388)
> >    at org.apache.log4j.Category.log(Category.java:853)
> >    at edu.unc.its.util.UNCLogger.prepareAndLogMessage(UNCLogger.java:445)
> >    at edu.unc.its.util.UNCLoggerClient.main(UNCLoggerClient.java:23)
> > log4j:ERROR JDBCAppender::flush_buffer(), :
> > java.sql.SQLException: Internal Error: Unable to construct a Datum from
> > the
> > specified input
> >    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
> >    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
> >    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:829)
> >    at oracle.sql.SQLUtil.makeDatum(SQLUtil.java:645)
> >    at oracle.sql.SQLUtil.makeOracleDatum(SQLUtil.java:946)
> >    at
> >
> oracle.jdbc.driver.UpdatableResultSet.updateObject(UpdatableResultSet.java:1568)
> >    at
> >
> oracle.jdbc.driver.OracleResultSet.updateObject(OracleResultSet.java:2787)
> >    at org.apache.log4j.jdbcplus.JDBCLogger.append(JDBCLogger.java:742)
> >    at
> >
> org.apache.log4j.jdbcplus.JDBCAppender.flush_buffer(JDBCAppender.java:887)
> >    at
> org.apache.log4j.jdbcplus.JDBCAppender.append(JDBCAppender.java:867)
> >    at
> > org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
> >    at
> >
> org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:65)
> >    at org.apache.log4j.Category.callAppenders(Category.java:203)
> >    at org.apache.log4j.Category.forcedLog(Category.java:388)
> >    at org.apache.log4j.Category.log(Category.java:853)
> >    at edu.unc.its.util.UNCLogger.prepareAndLogMessage(UNCLogger.java:445)
> >    at edu.unc.its.util.UNCLoggerClient.main(UNCLoggerClient.java:23)
> >
> >
> > Any suggestions as to how can I incorporate a CLOB datatype in JDBCPlus
> > jdbc
> > appender will be most welcome.
> >
> > Regards,
> > Vaibhav
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/CLOB-column-datatype-for-JDBCPlus-jdbc-appender-tp19306835p20682090.html
> Sent from the Log4j - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>

Mime
View raw message