File | Line |
---|
org/apache/log4j/xml/UtilLoggingXMLDecoder.java | 228 |
org/apache/log4j/xml/XMLDecoder.java | 231 |
String newPartialEvent = null;
//separate the string into the last portion ending with
// </log4j:event> (which will be processed) and the
// partial event which will be combined and
// processed in the next section
//if the document does not contain a record end,
// append it to the partial event string
if (document.lastIndexOf(RECORD_END) == -1) {
partialEvent = partialEvent + document;
return null;
}
if (document.lastIndexOf(RECORD_END)
+ RECORD_END.length() < document.length()) {
newDoc = document.substring(0,
document.lastIndexOf(RECORD_END) + RECORD_END.length());
newPartialEvent = document.substring(
document.lastIndexOf(RECORD_END) + RECORD_END.length());
} else {
newDoc = document;
}
if (partialEvent != null) {
newDoc = partialEvent + newDoc;
}
partialEvent = newPartialEvent;
Document doc = parse(newDoc);
if (doc == null) {
return null;
}
return decodeEvents(doc);
}
return null;
}
/**
* Converts the string data into an XML Document, and then soaks out the
* relevant bits to form a new LoggingEvent instance which can be used
* by any Log4j element locally.
* @param data XML fragment
* @return a single LoggingEvent
*/
public LoggingEvent decode(final String data) {
Document document = parse(data);
if (document == null) {
return null;
}
Vector events = decodeEvents(document);
if (events.size() > 0) {
return (LoggingEvent) events.firstElement();
}
return null;
}
/**
* Given a Document, converts the XML into a Vector of LoggingEvents.
* @param document XML document
* @return Vector of LoggingEvents
*/
private Vector decodeEvents(final Document document) {
Vector events = new Vector(); |
File | Line |
---|
org/apache/log4j/net/MulticastAppender.java | 74 |
org/apache/log4j/net/UDPAppender.java | 98 |
activateOptions();
}
/**
Open the UDP sender for the <b>RemoteHost</b> and <b>Port</b>.
*/
public void activateOptions() {
try {
hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException uhe) {
try {
hostname = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException uhe2) {
hostname = "unknown";
}
}
//allow system property of application to be primary
if (application == null) {
application = System.getProperty(Constants.APPLICATION_KEY);
} else {
if (System.getProperty(Constants.APPLICATION_KEY) != null) {
application = application + "-" + System.getProperty(Constants.APPLICATION_KEY);
}
}
if(remoteHost != null) {
address = getAddressByName(remoteHost); |
File | Line |
---|
org/apache/log4j/xml/XMLDecoder.java | 348 |
org/apache/log4j/xml/XMLDecoder.java | 386 |
NodeList propertyList = list.item(y).getChildNodes();
int propertyLength = propertyList.getLength();
for (int i = 0; i < propertyLength; i++) {
String propertyTag = propertyList.item(i).getNodeName();
if (propertyTag.equalsIgnoreCase("log4j:data")) {
Node property = propertyList.item(i);
String name =
property.getAttributes().getNamedItem("name").getNodeValue();
String value =
property.getAttributes().getNamedItem("value").getNodeValue();
properties.put(name, value);
}
}
}
/**
* We add all the additional properties to the properties
* hashtable. Don't override properties that already exist
*/
if (additionalProperties.size() > 0) { |
File | Line |
---|
org/apache/log4j/xml/UtilLoggingXMLDecoder.java | 382 |
org/apache/log4j/xml/XMLDecoder.java | 400 |
}
}
/**
* We add all the additional properties to the properties
* hashtable. Don't override properties that already exist
*/
if (additionalProperties.size() > 0) {
if (properties == null) {
properties = new Hashtable(additionalProperties);
} else {
Iterator i = additionalProperties.entrySet().iterator();
while (i.hasNext()) {
Map.Entry e = (Map.Entry) i.next();
if (!(properties.containsKey(e.getKey()))) {
properties.put(e.getKey(), e.getValue());
}
}
}
} |
File | Line |
---|
org/apache/log4j/net/SocketReceiver.java | 180 |
org/apache/log4j/net/XMLSocketReceiver.java | 160 |
getLogger().debug("{} doShutdown called", getName());
// close the server socket
closeServerSocket();
// close all of the accepted sockets
closeAllAcceptedSockets();
}
/**
* Closes the server socket, if created.
*/
private void closeServerSocket() {
getLogger().debug("{} closing server socket", getName());
try {
if (serverSocket != null) {
serverSocket.close();
}
} catch (Exception e) {
// ignore for now
}
serverSocket = null;
}
/**
* Closes all the connected sockets in the List.
*/
private synchronized void closeAllAcceptedSockets() {
for (int x = 0; x < socketList.size(); x++) {
try {
((Socket) socketList.get(x)).close();
} catch (Exception e) {
// ignore for now
}
} |
File | Line |
---|
org/apache/log4j/xml/UtilLoggingXMLDecoder.java | 427 |
org/apache/log4j/xml/XMLDecoder.java | 455 |
}
return events;
}
/**
* Get contents of CDATASection.
* @param n CDATASection
* @return text content of all text or CDATA children of node.
*/
private String getCData(final Node n) {
StringBuffer buf = new StringBuffer();
NodeList nl = n.getChildNodes();
for (int x = 0; x < nl.getLength(); x++) {
Node innerNode = nl.item(x);
if (
(innerNode.getNodeType() == Node.TEXT_NODE)
|| (innerNode.getNodeType() == Node.CDATA_SECTION_NODE)) {
buf.append(innerNode.getNodeValue());
}
}
return buf.toString();
}
} |
File | Line |
---|
org/apache/log4j/net/SocketNode13.java | 197 |
org/apache/log4j/net/XMLSocketNode.java | 172 |
}
}
} catch (java.io.EOFException e) {
getLogger().info("Caught java.io.EOFException closing connection.");
listenerException = e;
} catch (java.net.SocketException e) {
getLogger().info(
"Caught java.net.SocketException closing connection.");
listenerException = e;
} catch (IOException e) {
getLogger().info("Caught java.io.IOException: " + e);
getLogger().info("Closing connection.");
listenerException = e;
} catch (Exception e) {
getLogger().error("Unexpected exception. Closing connection.", e);
listenerException = e;
}
}
// close the socket
try {
if (is != null) { |