如何使用SLF4J或Logback将事件日志写入xml文件? [英] How to write event logs into xml files with SLF4J or Logback?

查看:162
本文介绍了如何使用SLF4J或Logback将事件日志写入xml文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个自定义的日志查看器,并且需要集成在.Net和Java平台中生成的日志文件.首先,我想知道是否可以使用SLF4J或logback将日志事件写成格式正确的xml格式. 有想法吗?

I want to create a customized log viewer and I need to integrate log files generated in .Net and Java platforms. First of All I want to know if I could write log events into a well-formed xml format with SLF4J or logback. Any Idea?

推荐答案

logback-classic支持log4j XML布局.参见此处: http://logback.qos.ch/manual/layouts.html

logback-classic supports the log4j XML layout. See here: http://logback.qos.ch/manual/layouts.html

关于SLF4J:它是一个日志记录外观,而不是一个记录程序.它提供了一种方便的方法来将日志记录API与实现分离,从而允许您稍后更改实际的日志记录库.但是,它本身不会记录其他任何内容,因此您无法将其配置为使用XML.

Regarding SLF4J: it is a logging facade, rather than a logger. It provides a convenient way to decouple your logging API from the implementation, allowing you to change the actual logging library later. However, it won't log anything else itself, so you can't configure it to use XML.

如果要使用SLF4J API和logback来执行实际的日志记录,则将需要适当的logback绑定jar.您可以在SLF4J网站上找到它.

If you want to use The SLF4J API and logback to perform the actual logging, you will need the appropriate logback binding jar. You can find it on the SLF4J web site.

这篇关于如何使用SLF4J或Logback将事件日志写入xml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆