appender - Log4j : How do I lookup the datasource in log4jconf.xml -
i using weblogic application deployment , have created datasource jndi name "mydatasource". when try use in log4j configuration, not working
<appender name="mydbappender" class="org.apache.log4j.jdbc.jdbcappender"> <param name="jndiname" value="mydatasource"/> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="insert logging (user_id, correlation_id, first_name, last_name, event_name, role, status, access_level, message, logger, loglevel) values ( '%x{user_id}', '%x{correlation_id}', '%x{first_name}', '%x{last_name}','%x{event_name}','%x{role}','%x{status}','%x {access_level}', '%m' , '%x{logger}','%p' )"/> </layout> </appender>
if want use feature, need add jar file of apache extras apache log4j , use class org.apache.log4j.dbappender
. e.g.:
<!-- console --> <appender name="stdout" class="org.apache.log4j.consoleappender"> <layout class="org.apache.log4j.simplelayout" /> </appender> <!-- db --> <appender name="dbout" class="org.apache.log4j.dbappender"> <connectionsource class="org.apache.log4j.receivers.db.jndiconnectionsource"> <param name="jndilocation" value="java:/comp/env/jdbc/mysqlds" /> </connectionsource> </appender> <!-- root --> <root> <priority value="all" /> <appender-ref ref="stdout" /> <appender-ref ref="dbout" /> </root>
Comments
Post a Comment