Abgeschickt von christoph am 21 Juli, 2006 um 13:30:11
Antwort auf: how logmessages will be stored in MYSQL... von reddy am 19 Juli, 2006 um 17:10:46:
i'd use the pattern layout!
eg. configure like
%m#%C{1}#%M#%L
and set layoutpartsdelimiter to #
so the insert
INSERT INTO myTabel(message, class, method, line) VALUES ('@MSG@','@LAYOUT:2@', '@LAYOUT:3@', '@LAYOUT:4@')
should insert the messagetest, the name of the calling class, the name of the calling method and the number of the line, where the call occures!
an examplecode could be:
PatternLayout layout = new PatternLayout("%m#%C{1}#%M#%L#%n");
Logger logger = Logger.getRootLogger();
JDBCAppender app = new JDBCAppender(); //being the ...jdbcplus.JDBCAppender
app.setLayout(layout);
app.setLayoutPartsDelimiter("#");
app.setUrl("<yourDatabaseUrl>");
app.setUsername("<yourDBUsername>");
app.setPassword("<yourDBUsersPwd>");
app.setSql("INSERT INTO myTabel(message, class, method, line) VALUES ('@MSG@','@LAYOUT:2@', '@LAYOUT:3@', '@LAYOUT:4@')");
app.setCommit(true);
logger.addAppender(app);
logger.debug("My debug message");
using dankos API would help if there are any problems left..
best regards,
christoph