log4j JDBCAppender rotate table name -


i have configured application uses log4j it's logging log mysql database. (using org.apache.log4j.jdbc.jdbcappender).

i have perl applications log database well. perl apps setup name of database table changes every month (log_2010_11, log_2010_10 etc). @ end of each month, run reporting scripts on month completed, dump table external file (which gets compressed , archived), , drop table. way total size of logging database stays within sensible limits.

i same log4j, there not appear log4j appender suitable purpose.

is possible this:

log4j.appender.sq=org.apache.log4j.jdbc.jdbcrollingappender  log4j.appender.sq.driver=com.mysql.jdbc.driver  log4j.appender.sq.url=jdbc:mysql://localhost:3306/logs_{%year}_{%month} 

thank you.

i figured out how this:

log4j.appender.sq=org.apache.log4j.jdbc.jdbcappender log4j.appender.sq.driver=com.mysql.jdbc.driver log4j.appender.sq.url=jdbc:mysql://localhost:3306/logs log4j.appender.sq.sql=insert accesslog_%d{yyyy_mm} (date, time, tz, ... 

it appears can put date format strings sql statement, , jdbcappender expand them , log coresponding table.

however, not create new tables @ start of new month, have manualy create tables beforehand, far ideal.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -