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 Quoting ysuneelreddy <[EMAIL PROTECTED]>: > Iam saying > If u want to change in Ur Log4j.xml u can change with out change class > I think it is better to write Log4j.properties instead of log4j.xml > No problem if u uses Log4j.xml > From > Suneel > > -----Original Message----- > From: Merin Shaji [mailto:[EMAIL PROTECTED] > Sent: Monday, August 21, 2006 5:24 PM > To: Log4J Users List > Subject: Re: JDBC Appender > > I could not understand what you meant. > > On 8/21/06, ysuneelreddy <[EMAIL PROTECTED]> wrote: > > > > Yes, IF u wants u can change > > It is not Effect... > > From > > Suneel > > > > > > -----Original Message----- > > From: Merin Shaji [mailto:[EMAIL PROTECTED] > > Sent: Monday, August 21, 2006 5:04 PM > > To: Log4J Users List > > Subject: Re: JDBC Appender > > > > Suneel, > > > > Can I change the configuration in log4j.xml and achieve this without > > changing my classes? > > The jdbc appender in my log4j.xml is: > > > > <appender name="SystemJdbcAppender" class=" > > org.apache.log4j.jdbcplus.JDBCAppender"> > > <param name="url" value="jdbc:oracle:thin:@172.20.20.51:1521:orcl"/> > > > > <param name="dbclass" value="oracle.jdbc.driver.OracleDriver"/> > > > > <param name="username" value="test123"/> > > > > <param name="password" value="test123"/> > > > > <param name="sql" value="INSERT INTO LOGSTABLE (id, prio, cat, thread, > > msg, > > throwable, the_timestamp, created_by) VALUES (@INC@, '@PRIO@', '@CAT@', > > '@THREAD@', '@MSG@', '@THROWABLE@', CURRENT_TIMESTAMP, 'user')"/> > > <param name="buffer" value="1"/> > > > > <param name="commit" value="true"/> > > <param name="quoteReplace" value="true"/> > > <param name="throwableMaxChars" value="2000"/> > > </appender> > > > > I want to replace the hardcoded 'user' value in the created_by field with > > the current user. Otherwise I can add a field for MDC/NDC in my table, as > > you said, and get the user name in that field. How can I do that? I have > > read that you can use %x in the conversion pattern and get the current > > user. > > How is this possible? > > Thanks & Regards > > Merin > > > > On 8/21/06, yaramaka reddy <[EMAIL PROTECTED]> wrote: > > > > > > I think > > > For this if u use MDC,NDC then u will get good results,,, > > > From > > > Suneel > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]