Do you have more than one version of Log4j in the classpath?  I would also be
wary of using Log4j-1.3 alpha in production.  Best to stick with the 1.2.xx
series.

Jake

Quoting Merin Shaji <[EMAIL PROTECTED]>:

> Jake,
>
> Thanks for your reply. I tried out NDC and is working fine.
>
> But I could not use MDC. It gave the following error:
>
> java.lang.NoSuchMethodError: org.apache.log4j.spi.LoggingEvent.getMDC
> (Ljava/lang/String;)Ljava/lang/Object;
>
> I am using log4j-1.3alpha0.jar and a jdbcappender which extends log4j (
> org.apache.log4j.jdbcplus)
>
> My code snippet is:
>
> *Logger loggerObj = LoggerFactory.getLogger("UsageLogger");*
>
> *NDC.push(sessionUser);*
>
> *MDC.put("LogUrl",url);*
>
> *loggerObj.info("MDC test");*
>
> *NDC.pop();*
>
> *MDC.remove("LogUrl");*
>
> My log4j.xml entry is:
>
> *<param **name="sql" value="INSERT INTO LOGSTAB (id, prio, cat, thread, msg,
> throwable, ndc, mdc, the_timestamp) VALUES (FELIXLOGS_SEQ.NEXTVAL,@INC@,
> '@PRIO@', '@CAT@', '@THREAD@', '@MSG@', '@THROWABLE@', '@NDC@',
> '@MDC:LogUrl@', CURRENT_TIMESTAMP)"** />*
>
> Why is it happening? I understand that you can store only one value in the
> database using NDC. Please correct me if I am wrong.
>
> Thanks & Regards
>
> Merin
>
>
> On 8/21/06, Jacob Kjome <[EMAIL PROTECTED]> wrote:
> >
> >
> > If you want to use MDC or NDC, you will have to register the values using
> > your
> > classes.  However, once you have that, you can redefine the layout of your
> > appender in the config file without changing your classes.  This article
> > provides both an example of a JDBCAppender configuration and talks about
> > MDC
> > and NDC.  They are discussed separately, but you can extrapolate on how
> > you
> > would add the MDC/NDC values in your layout...
> >
> > http://www.onjava.com/pub/a/onjava/2002/08/07/log4j.html?page=3
> >
> >
> > Jake
>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to