@@ -0,0 +1,1878 @@
+package com.xrtb.tools;%0A%0Aimport java.text.SimpleDateFormat;%0A%0A%0Aimport java.util.Date;%0Aimport java.util.Deque;%0A%0Aimport org.apache.log4j.AppenderSkeleton;%0Aimport org.apache.log4j.spi.LoggingEvent;%0A%0Aimport com.xrtb.bidder.ZPublisher;%0A%0A/**%0A * A class to log log4j messages to memory, for use by the web api.%0A * See: https://mytechattempts.wordpress.com/2011/05/10/log4j-custom-memory-appender%0A * @author Ben M. Faul%0A *%0A */%0A%0Apublic class Zpublsiher4J extends AppenderSkeleton %7B%0A%09/** Formatter for the date time string */%0A%09static SimpleDateFormat sdf = new SimpleDateFormat(%22yyyy-MM-dd HH:mm:ss.SSS%22);%0A%0A%09/** The publisher to be used by this Log4j appender */%0A%09ZPublisher publisher;%0A%09%0A%09/**%0A%09 * Set the Publisher using the url string%0A%09 * @param str String. The ZPublisher string.%0A%09 */%0A%09public void setPublisher(String str) %7B%0A%09%09try %7B%0A%09%09%09publisher = new ZPublisher(str);%0A%09%09%7D catch (Exception error) %7B%0A%09%09%09System.out.println(%22Log4j failed to open ZPublisher: %22 + str);%0A%09%09%7D%0A%09%7D%0A%09/**%0A%09 * Close the appender%0A%09 */%0A%09public synchronized void close() %7B%0A%09%09if (this.closed) %7B%0A%09%09%09return;%0A%09%09%7D%0A%09%09this.closed = true;%0A%09%7D%0A%0A%09/**%0A%09 * Indicate we want the layout%0A%09 */%0A%09public boolean requiresLayout() %7B%0A%09%09return true;%0A%09%7D%0A%0A%09/**%0A%09 * Make sure we can append%0A%09 * @return boolean. Returns true if we are accepting logs.%0A%09 */%0A%09protected boolean checkEntryConditions() %7B%0A%09%09if (this.closed) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%09%09return true;%0A%09%7D%0A%0A%09/**%0A%09 * Append the log to ZPublisher%0A%09 * @param event LoggingEvent. The log event to format and send to the log.%0A%09 */%0A%09protected void append(LoggingEvent event) %7B%0A%09%09String name = event.getLocationInformation().getClassName();%0A%09%09name = name.substring(name.lastIndexOf(%22.%22)+1);%0A%09%09String s = String.format(%22%25s %25s %25s:%25s - %25s%3Cbr%3E%22, sdf.format(new Date()),%0A%09%09%09%09event.getLevel(),name,event.getLocationInformation().getLineNumber(), event.getRenderedMessage());%0A%09%09publisher.addString(s);%0A%09%7D%0A%7D

Add new capability to send log4j messages over 0MQ