Reputation: 11906
I have a Swing-based application that logs all messages to text files through slf4j with logback underneath.
I'd like to add a feature to show all messages at a certain level(e.g. fatal) logged in the current session on demand, say in a JTable
.
Does slf4j provide API that lets you access historical log messages, preferably filtered by level or time?
Upvotes: 2
Views: 328
Reputation: 15758
Try to use Logback, there is a ch.qos.logback.classic.db.DBAppender
class that you can use as an Appender to your fatal errors. You can define your own data structure, just provide the SQL Insert
statement. Also, other variants of this DBAppender
are provided, so you can choose when do you want to customize the behavior.
The next thing is that you tie your appender to those loggers that you want to log.
Finally you can manage your logged data within your application (filter, purge/archive) just like your application business data.
Upvotes: 0