Integrated log4J to Eclipse - "Eclipse In Action" Chapter 9 (1)

xiaoxiao2021-03-06  79

1, log4j integrated plugin overview

(1) strategy

Using separate plugins: A package for encapsulating open source libraries (such as log4j library plugins), one for implementing Eclipse integration (this article is to be introduced). The latter relies on the former.

(2) Main features of log4j integrated plugins

l log4j.properties editor: including syntax color and code assistance

l Logging for log events specifying Socket (default is 4455): Display log events in the table

l Mark the modulator of all Java files that currently use logs

l Pop-up menu item: Automatically add a log to the source code for the Java file

l PREFERENCES of the plugin

(3) Log4j.properties sample

# Assign Appenders to root logger

Log4j.rootlogger = debug, mysocket

# Socket Appender - Make Sure The Port Number Agrees with The

# setting of the log4j preferences.

Log4j.Appender.mysocket = org.apache.log4j.net.socketAppender

Log4j.Appender.mysocket.remotehost = localhost

Log4j.Appender.Mysocket.LocationInfo = TRUE

Log4j.appender.mysocket.port = 4445

(4) Creating a log4j integrated plugin framework

l File> New> Plug-in Project

l Enter the project name: org.xqtu.log4j

l Specify the provider name: Nelson_tu

l Click the Finish button to complete the project creation

l Double-click PLUGIN.XML to open the list editor

l On the Dependencies option page, click the Add button, select Org.Apache.log4j (log4j class library plugin)

转载请注明原文地址:https://www.9cbs.com/read-107447.html

New Post(0)