Web Service Appender management log record
Introduction <br> <br> you can use the Web Service Appender to log to a centralized location, at the same time, Web Service Appender allows managers to monitor, developers debugging service-oriented architecture (SOA) environment that may exist in any problems. Web Service Appender is a JAVA-type expansion, which is the expansion of Log4j category from the Appender.
By definition, SOA is a mutual communication between the services can be set, but the contents of these services are separate, each type of service are not subject to other state services or the impact of services and these services are working in the distribution of structure of the system. In the SOA in, Web services are often used to deal with the affairs of a given request, these requests can be left over code, enterprise-class java Beans (EJBs) package, it could be a java class package can use a log information gathered at the center of the log record in the methods, can help you isolate defects and problems, and allows you to better understand the logic of the deal flow.
Specific module or service record log messages to a central location of the mechanism, can be potential problems and to minimize defects.
In this paper, the functions of Log4j a general overview, and describes how to prepare a custom Log4j Appender, such special provision Appender to log messages to a specific Web service.
Quick Start Log4j is an open source Log4j log database, it has been developed for the Apache software foundation projects in sub-log service. The database is based on IBM in the late 90's developed based on the log database, the first edition published in 1999. It is now open-source groups have been widely used, it is the system around the following three key concepts to build up:
These concepts will allow you to type messages, message priority to record information, you can control where the end of the news and information on how to format. Logger is an application to the first call to initialize the object information record. When a message to the log, logger generates LoggingEvent, encapsulation of the message. After, Logger object will be passed on to LoggingEvent associated Appender.
Appender will be included in LoggingEvent send a message to the specified target output file. The so-called specified file, in most cases is Log4 document properties. Exist in a number of Appender in Log4j. You can also expand the Appender, to support the objectives of other documents, such as xml documents, so the console.
Log4j years in, LoggingEvent been given a certain level, to show their priority. The level of default, including the following:
OFF: the highest possible level, which is used to close the log record FATAL: refers to a very serious error events, these errors may lead to abnormal termination application ERROR: Although the error means, but still allow the application to continue running WARN: operating environment refers to the harm hidden INFO: The report refers to information in the coarse-grained level to highlight the process of application DEBUG: fine-grained information refers to events, fine-grained information on events for debugging applications is the most useful The ALL: is the lowest level possible, and its aim is to open all Appender logging Logger and also be given a level above, and only the implementation of equal to or higher than their own log-level request. For example, if a belongs to INFO level Appender, and log the request belongs to DEBUG, then Appender will not log for a given event to write the news.
Client Components <br> <br> client client log4j.properties file log4j.properties file is a standard document, which includes the use of services or modules all Appender. Web Service Appender endpoint requires a (endpoint) attributes used to specify the log service.
1 describes a list of WebServiceAppender necessary for the use of Web services client Log4j properties. Bold text WebServiceAppender specified a server-side will visit the Appender. Log4j properties file is to use the basic needs, which allows you to configure applications to use multiple Appender and logging severity. Once entered the running state of applications or potential problems are solved, you can easily modify the properties file.
List 1: Log4j properties of the client file # set the level of the root logger log
4j.rootLogger = INFO, CONSOLE
# set own loggerlog
4j.logger.com.carmelouria.logging.test = CONSOLElog
4j.appender.CONSOLE = com.carmelouria.logging.WebServiceAppenderlog
4j.appender.CONSOLE.layout = org.apache.log
4j.appender.CONSOLE.layout.ConversionPattern =% p [% t]% c (2) (% M:% L)::% m% n
Log4j.properties server file server file Log4j.properties be used to link client Log4j properties file, which specifies the log level and how the output message server. Log4j for the support of the application, you can define multiple appender. Of course, these can be used not only appender client services, service modules can also be used.
2 describes a list of typical Log4j properties file, server-side default WebServiceAppender use Log4j Appenders. Server-side potential of the Appender can call another WebServiceAppender, log information and links:
List 2: server-side of the Log4j properties file # set the level of the root logger log
4j.rootLogger = INFO, FILE
# set own loggerlog
4j.appender.FILE = org.apache.log
4j.appender.FILE.file = c: / temp / log
4j.appender.FILE.layout = org.apache.log
4j.appender.FILE.layout.ConversionPattern =% p [% t]% C++ (2) (% M:% L)::% m% n
Test client program example:
The sample client program format is no ordinary Java objects (POJO), it recorded a message, and configured to use Web Service Appender to deal with the news. 3 shows the list of examples:
List 3: client application WebServiceAppender examples of the use of package com.carmelouria.logging.test;
* @ Author Carmelo Uria
* / public class LoggingSample
private static Logger logger = Logger.getLogger (LoggingSample.class.getName ());
public LoggingSample ()
PropertyConfigurator.configure ( "c: / temp/log4j.properties");
logger.log (Level.INFO, "LoggingSample instantiation ...");
System.out.println ( "finished ...");
public static void main (String  args)
LoggingSample sample = new LoggingSample ();
WebServiceAppender is necessary, it can send a message to the specified Web service. WebServiceAppender inherited org.log4j.Appender, it allows the use of log4.properties, and become effective Log4j Appender.
WebServiceAppender the use of XML-based Remote Procedure Call (JAX-RPC) of the Java API, to send a message to the server. JAX-RPC is a specification, which describes the use of RPC and xml to build Web services and Web service client application programming interface (API) and agreed. JAX-RPC is also known as JSR 101.
SOAPElement be divided through LoggingEvent and said that XML. means that the service endpoint interface javax.xml.soap.SOAPElement interface will contain a parameter or return value types of javax.xml.soap.SOAPElement to correspond to each of the use of schema
List 4: implementation of Append method WebServiceAppender services protected void append (LoggingEvent event)
/ / Create Web Service client using endpoint
if (endpoint == null)
System.out.println ( "no endpoint set. Check configuration file");
System.out.println ( "[" + hostname + "]" + this.layout.format (event));
private void executeWebService (LoggingEvent event)
SoapClient client = new SoapClient ();
URL endPoint = null;
endPoint = new URL (getendpoint ());
catch (MalformedURLException e1)
String nameSpace = "http://ejb.logging.carmelouria.com";
QName serviceName = new QName (nameSpace, "LogAppenderServiceService");
QName operation = new QName (nameSpace, "log");
QName port = new QName (nameSpace, "LogAppenderService");
Parameter message =
new Parameter ( "log", Constants.XSD_ANY, SOAPElement.class, ParameterMode.IN);
Java and XML Articles
- Dynamic WEB application in the creation of PDF documents
- Environment variable with the deployment of custom applications on the Web to discuss the scope of layer properties
- Web Application Framework for JDBC-ODBC configuration
- Learn to how to use Java Web Start application deployment
- Web applications, how to start the background task
- Manually created namespace SOAP message processing
- Web Service Appender management log record
- Spring WebFlow: 2 (WebFlow of key components)
- Spring WebFlow: 3 (WebFlow achieve reuse)
- Axis 1.1 for Java for Web Services Development
- Technical Analysis: Based on the Custom Axis Object Serialization
- To adapt to multi-database environment ConnectionManager
- Eclipse plug-ins to achieve Axis WebService client
- JWSDP completed using the Web Service entry in java (a)
- JWSDP completed using the Web Service entry in the java (b)
- Learn to teach you the basis of XML Web Service
- Apache Img Tag used to generate images immediately verify
- Advanced article master: Jive in the use of analytical Jdom
- Analysis of Web Service development of different levels
- WSDL in the Web Service in the meaning and role of
Can't Find What You're Looking For?