#63 Add JDBCAppender feature

1.1 release
open
nobody
audit (3)
7
2008-05-03
2008-05-03
André Pestana
No

jGuard should create a log table and bring a commented JDBCAppender configuration like above:

# A sample conf for logging JG_AUDIT level in database
# It could come commented with jguard-struts-example
# An example config file for JDBCAppender:
log4j.rootCategory=DEBUG, jdbc

# JDBCAppender writes messages into the database
log4j.appender.jdbc=org.apache.log4j.jdbc.JDBCAppender

#SQL statement to be used (with multiple columns formated)
log4j.appender.jdbc.sql=insert into jg_log (application, user, action, parameters, success, priority, log_date) values ('jGuard_Portal', '%X{user}', '%m', '%X{parameters}', '%X{success}', '%p', NOW());

# DB Options
log4j.appender.jdbc.driver=com.mysql.jdbc.Driver
log4j.appender.jdbc.URL=jdbc:mysql://localhost:3306/jguard?connectionCollation=utf8_general_ci
log4j.appender.jdbc.user=root
log4j.appender.jdbc.password=secret
log4j.appender.jdbc.threshold=JG_AUDIT#net.sf.jguard.audit.JGLevel

#set the buffer size
log4j.appender.JDBC.buffersize=1

Table definition for MySQL:
CREATE TABLE jg_log(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
application varchar(255),
user varchar(255),
action VARCHAR(1000),
parameters varchar(1000),
success int(1),
priority VARCHAR(255),
log_date datetime );

Discussion