Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
726 views
in Technique[技术] by (71.8m points)

logging - A good database log appender for Java?

At my workplace, we wrote a custom log4j appender that writes log messages to the database (uses a dedicated thread asynchronously, so no performance hit). I prefer it a lot over writing to log files - a database-based log is much more easy to query and analyze.

Is there an open source solution that does this (for log4j specifically, or any other java loggers)?

Some things that our appender has, and I would like to see in an alternative:

  • Logs exceptions (duh!)
  • Database writes are from a separate thread/pool

Our appender supports the following columns, and I would like to see all of them in whatever solution we find.

  • LogId
  • Time
  • message
  • stacktrace
  • process id
  • thread id
  • machine name
  • component
  • Level (debug/info/warn/...)
  • ThreadName
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is also a DBAppender class provided by log4j (log4j requires a specific set of tables to log using this appender). http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/db/DBAppender.html

There is an updated non-Apache jdbc logger available here you may also want to try: http://www.dankomannhaupt.de/projects/index.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...