1 4 package com.tc.logging; 5 6 import org.apache.log4j.AppenderSkeleton; 7 import org.apache.log4j.spi.LoggingEvent; 8 9 import com.tc.exception.TCRuntimeException; 10 import com.tc.management.beans.logging.TCLoggingBroadcaster; 11 import com.tc.management.beans.logging.TCLoggingBroadcasterMBean; 12 13 import javax.management.NotCompliantMBeanException ; 14 15 22 public class JMXAppender extends AppenderSkeleton { 23 24 private final TCLoggingBroadcaster broadcastingBean; 25 26 public JMXAppender() { 27 try { 28 broadcastingBean = new TCLoggingBroadcaster(); 29 } catch (NotCompliantMBeanException ncmbe) { 30 throw new TCRuntimeException("Unable to construct the broadcasting MBean: this is a programming error in " 31 + TCLoggingBroadcaster.class.getName(), ncmbe); 32 } 33 } 34 35 public final TCLoggingBroadcasterMBean getMBean() { 36 return broadcastingBean; 37 } 38 39 protected void append(final LoggingEvent event) { 40 broadcastingBean.broadcastLogEvent(getLayout().format(event)); 41 } 42 43 public boolean requiresLayout() { 44 return false; 45 } 46 47 public void close() { 48 } 50 51 } 52 | Popular Tags |