且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Log4j记录到共享日志文件

更新时间:2023-01-13 13:15:06

Log4j具有SocketAppender,它将向服务发送事件,您可以自己实现该事件,也可以使用与Log4j捆绑在一起的简单实现.

Log4j has a SocketAppender, which will send events to a service, which you can implement yourself or use the simple implementation bundled with Log4j.

它还支持syslogd和Windows事件日志,这对于尝试将日志输出与非Java应用程序中的事件统一起来很有用.

It also supports syslogd and the Windows event log, which may be useful in trying to unify your log output with events from non-Java applications.

如果性能根本不成问题,则您需要一个服务来编写日志文件,而不是尝试在各种日志应用程序之间协调一致的锁定策略.

If performance is an issue at all, you want a single service writing the log file, rather than trying to coordinate a consistent locking strategy among diverse logging applications.