0

I would like to write a GUI application that has a big control in it that displays output of logging.

It would have a dropdown menu to filter it.

So therefore I need to find a Logging library for java that allows me to:

  1. Create a custom class to interface with the output, so that i can redirect it to my GUI control

  2. Allow me to assign a custom tag to what I am logging...

    e.g. log("abc", "it's tuesday")

    e.g. log("def", "it's 2013")

    e.g. log("ghi", "logging is tedious")

  3. This is optional but I really would like it... ability to filter based on multiple of these tags... e.g. show output of "abc" and "def" but not "ghi"

Any suggestions? and, if you can, please list any other reasons the suggest library is good to use.

thanks.

4

3 回答 3

4

看看Slf4J + Logback。Slf4j 是一个抽象的日志 API,被许多(如果不是大多数)操作系统项目使用,而 Logback 恕我直言是最好的日志实现。

Slf4J 支持Markers,你可以用它来标记你的日志输出。

Logback 支持高级过滤配置:http ://logback.qos.ch/manual/filters.html 。

您可以创建自己的Appender以将数据发送到任何输出源。

一般来说,您也可以使用记录器的层次结构(例如 org.myapp.abc、org.myapp.performance 等)来组织您的输出。

于 2013-08-07T07:55:12.313 回答
1

结合 SLF4J + Logback 看看

  1. 您可以为此目的创建自定义附加程序。我什至记得有人开发了类似的 GUI,您已经可以使用

  2. SLF4J 中的标记似乎是执行“标记”的好人选

  3. 是的,SLF4J + Logback 确实允许您根据附加在日志事件中的标记进行过滤

于 2013-08-07T07:59:49.717 回答
0

根据您愿意编写多少代码,您可以使用 java SE logger 执行此操作:

自定义日志级别

您可以简单地创建所需 tpye 的记录器并使用它们,对于其他功能,请使用正则表达式模式。

这不是最简单的方法,但您可能拥有所需的所有控制权。

于 2013-08-07T07:44:04.037 回答