Imagine that the log output of the WebLogic Platform domain is configurable, in $ bea / weblogic / common / lib / workshoplogcfg.xml, the original project all log outputs are configured in this file. Other middleware I use very little, I believe there are similar functions, the log4j log frame supports the unified log management function, simple implementation principle (launching a socketserver, handling the socket input of each client machine, and each application printing log Using socket mode Output log content to the SocketServer end). If you can analyze the important middleware exception log and the application exception log to the unified log server, you can analyze real-time monitoring, which is convenient for daily monitoring, a bit similar to the function of the device alarm, if you have developed related log analysis software, your personal feeling is a platform A highlight of the grade product, as "Shaolin Football" said something a bit.
Practice: Practice proves reality and ideals have a certain gap, huh, huh. The following describes the verification, learning experience: First describing how the log4j implements the unified log to manage this feature. Core Class: 1, org.apache.log4j.net.socketServer Main features: 1. Start SocketServer 2, accept the Socket request 3, initialize the log output configuration of the corresponding socket, if not, use General Configuration 4, another check thread End Socket and the server interacts a comparison standard multi-threaded process implementation. Starting Server requires three run parameters: port number, log4j profile, client log in the server output profile directory running command as follows: java -classpath ../ lib / log4j-1.2.8.jar;.; Test.logserver .FixsocketServer 8088 Server.properties D: / Temp Description: a, client log In Server-side output configuration file naming rules $ IP.LCF, such as 10.21.11.10.lcf This class should have a bug in the code of the configuration file. (Version 1.2.9) code 176 row string key = s.substring (0, i); change to: string key = s.substring (i 1); b, configuration file content and general log4j configuration content Lei, Categories, Appenders, Layouts II, org.apache.log4j.net.socketAppender This class inherits in the appenderskelet, if we need to customize appender, you can inherit the appenderskeleton class, implement the method:
protected
Void
Append (loggingEvent event);
Key Functions: 1. Connect to SocketServer, and create a target output instance 2 to SocketServer, if the connection fails, start a daemon, reconnect every 30 seconds, log output, output the log event object to SocketServer corresponds to log configuration: log4j.appender.mysocket
=
Test.logserver.socketappender log4j.Appender.mysocket.Remotehost
=
10.243
.
17.85
Log4j.appender.mysocket.port
=
8088
Log4j.Appender.Mysocket.LocationInfo
=
True
Log4j.Appender.mysocket.layout
=
Org.apache.log4j.patternlayout log4j.appender.myconsole.Layout.ConversionPattern
=%
5P [
%
t]
%
F:
%
L)
-
%
M
%
n
Third, org.apache.log4j.net.socketnode This class is relatively simple, a thread class main function: responsible for receiving the client corresponding to the output object, outputting the relevant log according to the corresponding configuration. It can be seen that it is transmitted by the object. If the third party is not using Java language, simply rewrite the SocketAppender's APPEND method, and output the log content. The other party implements the socketserver function (the programming language is basically supported). Unfortunately, in the WEBLOGIC average, I didn't find where you changed the log output (the last time you see the log service in WebLogic9.0, you don't know if you can change), so the actual gap is more big, regarding performance issues, Because it is an important log (Warning, Error, Fetal) to output, the Socket method should be not big. Extragraph: Viewing the log4j framework part of the log4j framework is some people donated. Although the code is not complicated, it feels very enthusiastic for the framework you like. I hope that it will become better and better. I really hope that we can also have some excellent open source projects, and everyone will support it and develop it. Really I use log4j in the project, it is some basic functions. It is not very clear about it. Who has related learning documents, please give me a copy, I am not very grateful (use the manual).