Is there some library that has something like log4j logger
that would persist exception to database instead of log file? I'm using Spring, Hibernate and MySql combo most of the time so anything that would integrate with them would be great.
Asked
Active
Viewed 2,279 times
0

MatBanik
- 26,356
- 39
- 116
- 178
-
possible duplicate of [Log to a database using log4j](http://stackoverflow.com/questions/1364322/log-to-a-database-using-log4j) – Stephen C Jun 25 '11 at 04:28
-
possible duplicate of [A good database log appender for Java?](http://stackoverflow.com/questions/4157769/a-good-database-log-appender-for-java) – Vineet Reynolds Jun 25 '11 at 04:29
-
if you need to use log4j, and if you are avoiding JDBCAppender because it doesn't log exceptions, then take a look at DBAppender. – Vineet Reynolds Jun 25 '11 at 04:31
1 Answers
2
Actually, after a little GISing it seems that log4j can store it's output in any JDBC-compatible database with a little in-code logging logic and the proper log4j configuration (I actually did not know it could do this so...thanks for asking the question I guess).
I found a tutorial at http://www.cubrid.org/store_java_logs_to_databdase_using_log4j so have at it. It uses the Cubrid database, but it should be fairly easy to adapt to mysql/postgresql/firebird/etc (again, a few minutes on google turns up a number of how-to's and tutorials. Had to GIS "log4j mysql config" instead of something logical like "log4j mysql tutorial" which turned up nothing useful for whatever reason).

cyan_jeff
- 101
- 3
-
1Err, JDBCAppender does not log exceptions. That's quite a big thing. – Vineet Reynolds Jun 25 '11 at 04:33
-
Vineet is absolutely right, so strictly speaking this is not a correct answer – anton1980 Mar 11 '15 at 18:38