1 17 package org.apache.log.output.lf5; 18 19 import org.apache.log.LogEvent; 20 import org.apache.log.LogTarget; 21 import org.apache.log.format.Formatter; 22 import org.apache.log.format.PatternFormatter; 23 import org.apache.log4j.lf5.viewer.LogBrokerMonitor; 24 25 33 public class LF5LogTarget implements LogTarget 34 { 35 36 private static LogBrokerMonitor c_defaultLogMonitor; 37 38 39 private static Formatter c_defaultContextFormatter = new PatternFormatter( "" ); 40 41 42 private LogBrokerMonitor m_monitor; 43 44 45 private Formatter m_contextFormatter = c_defaultContextFormatter; 46 47 51 public LF5LogTarget( final LogBrokerMonitor monitor ) 52 { 53 m_monitor = monitor; 54 } 55 56 59 public LF5LogTarget() 60 { 61 } 64 65 70 public void setNDCFormatter( final Formatter formatter ) 71 { 72 m_contextFormatter = formatter; 73 } 74 75 80 public static synchronized LogBrokerMonitor getDefaultMonitor() 81 { 82 if( null == c_defaultLogMonitor ) 83 { 84 c_defaultLogMonitor = new LogBrokerMonitor( LogKitLogRecord.LOGKIT_LOGLEVELS ); 85 c_defaultLogMonitor.setFontSize( 12 ); 86 c_defaultLogMonitor.show(); 87 } 88 89 return c_defaultLogMonitor; 90 } 91 92 97 public void processEvent( final LogEvent event ) 98 { 99 if( null == m_monitor ) 100 { 101 m_monitor = getDefaultMonitor(); 102 } 103 104 m_monitor.addMessage( new LogKitLogRecord( event, m_contextFormatter ) ); 105 } 106 } 107 | Popular Tags |