2

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?

Tom Tucker
  • 11,676
  • 22
  • 89
  • 130
  • Not what you asked, but it's related: http://stackoverflow.com/questions/11643872/any-good-tutorials-on-lilith-log-viewer-for-logback – Darius X. Jun 12 '13 at 21:23

1 Answers1

0

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.

gaborsch
  • 15,408
  • 6
  • 37
  • 48