public void doAppend( LoggingEvent event ) { String line = layout.format( event ); System.out.println( line ); }
/** * By default getLogStatement sends the event to the required Layout object. * The layout will format the given pattern into a workable SQL string. * * Overriding this provides direct access to the LoggingEvent * when constructing the logging statement. * */ protected String getLogStatement(LoggingEvent event) { return getLayout().format(event); }
public void doAppend( LoggingEvent event ) { String line = layout.format( event ) + Const.CR; try { pipedOutputStream.write( line.getBytes() ); } catch ( IOException e ) { System.out.println( "Unable to write to piped output stream : " + e.getMessage() ); } }
public void doAppend( LoggingEvent event ) { String line = layout.format( event ) + Const.CR; try { fileOutputStream.write( line.getBytes( Const.XML_ENCODING ) ); } catch ( IOException e ) { System.out.println( "Unable to close Logging file [" + file.getName() + "] : " + e.getMessage() ); } }
public void doAppend( LoggingEvent event ) { String line = layout.format( event ) + Const.CR; buffer.append( line ); // See if we don't have too many lines on board... nrLines++; if ( maxNrLines > 0 && nrLines > maxNrLines ) { buffer.delete( 0, line.length() ); nrLines--; } for ( BufferChangedListener listener : bufferChangedListeners ) { listener.contentWasAdded( buffer, line, nrLines ); } }
public List<String> getLogs(long timestamp) { List<String> rt = new ArrayList<String>(); List<LoggingEvent> copiedEvents = this.getEvents(); for (LoggingEvent event : copiedEvents) { if (event.timeStamp > timestamp) { rt.add(this.layout.format(event)); } } return rt; }
public void append(LoggingEvent event) { StringBuffer sbuf = new StringBuffer(); sbuf.append(layout.format(event)); if(layout.ignoresThrowable()) { String[] s = event.getThrowableStrRep(); if (s != null) { int len = s.length; for(int i = 0; i < len; i++) { sbuf.append(s[i]); } } } // Normalize the log message level into the supported categories int nt_category = event.getLevel().toInt(); // Anything above FATAL or below DEBUG is labeled as INFO. //if (nt_category > FATAL || nt_category < DEBUG) { // nt_category = INFO; //} reportEvent(_handle, sbuf.toString(), nt_category); }
/** Handles a log event. For this appender, that means writing the message to each connected client. */ protected void append(LoggingEvent event) { if(sh != null) { sh.send(layout.format(event)); if(layout.ignoresThrowable()) { String[] s = event.getThrowableStrRep(); if (s != null) { StringBuffer buf = new StringBuffer(); for(int i = 0; i < s.length; i++) { buf.append(s[i]); buf.append("\r\n"); } sh.send(buf.toString()); } } } }
sbuf.append(layout.format(event)); if(layout.ignoresThrowable()) { String[] s = event.getThrowableStrRep();
@Override public String format(LoggingEvent event) { if(lineLayout == null) { return messageLayout == null ? event.getRenderedMessage() : messageLayout.format(event); } String message = event.getRenderedMessage(); String[] lines; String[] throwable; if(messageLayout == null && (throwable = event.getThrowableStrRep()) != null) { lines = throwable; } else if(message != null) { lines = message.split("\r?\n"); } else { lines = new String[0]; } StringBuffer strBuf = new StringBuffer(); for (String line : lines) { String formattedLine = lineLayout.format(replaceEventMessageWithoutThrowable(event, line)); strBuf.append(formattedLine); } String formattedLines = strBuf.toString(); if (messageLayout == null) return formattedLines; return messageLayout.format(replaceEventMessage(event, formattedLines)); }
/** * Info,error,warn,callback method implementation */ public void append(LoggingEvent event) { if (null == producer) { return; } if (locationInfo) { event.getLocationInformation(); } byte[] data = this.layout.format(event).getBytes(); try { Message msg = new Message(topic, tag, data); msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOG4J_APPENDER); //Send message and do not wait for the ack from the message broker. producer.sendOneway(msg); } catch (Exception e) { String msg = new String(data); errorHandler.error("Could not send message in RocketmqLog4jAppender [" + name + "].Message is :" + msg, e, ErrorCode.GENERIC_FAILURE); } }
packet = String.valueOf(event.getMessage()); } else { packet = layout.format(event);
/** * {@inheritDoc} */ @Override protected void append(LoggingEvent event) { final Throwable throwable; if (event.getThrowableInformation() == null) { throwable = null; } else { throwable = event.getThrowableInformation().getThrowable(); } LoggingHandler.addErrorLogToCounter(getLayout().format(event), throwable); }
@Override protected void append( LoggingEvent event ) { String s = layout.format( event ); if ( Level.DEBUG.equals( event.getLevel() ) ) { log.logDebug( s ); } else if ( Level.ERROR.equals( event.getLevel() ) || Level.FATAL.equals( event.getLevel() ) ) { Throwable t = event.getThrowableInformation() == null ? null : event.getThrowableInformation().getThrowable(); if ( t == null ) { log.logError( s ); } else { log.logError( s, t ); } } else if ( Level.TRACE.equals( event.getLevel() ) ) { log.logRowlevel( s ); } else if ( Level.OFF.equals( event.getLevel() ) ) { log.logMinimal( s ); } else { // ALL, WARN, INFO, or others log.logBasic( s ); } }
packet = String.valueOf(event.getMessage()); } else { packet = layout.format(event);
/** Actual writing occurs here. <p>Most subclasses of <code>WriterAppender</code> will need to override this method. @since 0.9.0 */ protected void subAppend(LoggingEvent event) { this.qw.write(this.layout.format(event)); if(layout.ignoresThrowable()) { String[] s = event.getThrowableStrRep(); if (s != null) { int len = s.length; for(int i = 0; i < len; i++) { this.qw.write(s[i]); this.qw.write(Layout.LINE_SEP); } } } if(shouldFlush(event)) { this.qw.flush(); } }
loggingEvent.getNDC(), loggingEvent.getLocationInformation(), loggingEvent.getProperties()); msg = layout.format(singleLoggingEvent); } else { msg = message.toString();
/** * By default getLogStatement sends the event to the required Layout object. * The layout will format the given pattern into a workable SQL string. * * Overriding this provides direct access to the LoggingEvent * when constructing the logging statement. * */ protected String getLogStatement(LoggingEvent event) { return getLayout().format(event); }
public List<String> getLogLines() { List<String> logLines = new ArrayList<>(buffer.size()); Layout layout = this.getLayout(); for (Object aBuffer : buffer) { LoggingEvent loggingEvent = (LoggingEvent) aBuffer; logLines.add(layout.format(loggingEvent)); } return logLines; }
@Override public void append(LoggingEvent event) { if (event == null) return; String line = this.layout.format(event); this.lines.add(line); if (event.getThrowableInformation() != null) { for (String t: event.getThrowableStrRep()) this.lines.add(t + "\n"); } clean(this.maxlines); }