/** * Create an appender for a given JNode console. * * @param layout the appender's initial log message layout. * @param toErr if <code>true</code> output to System.err, otherwise output to System.out. */ public JNodeSystemAppender(Layout layout, boolean toErr) { super(); this.layout = layout; this.immediateFlush = true; this.writer = new SystemStreamWriter(toErr); super.setWriter(this.writer); }
@Override public synchronized void setWriter(Writer writer) { if (writer != this.writer) { throw new IllegalArgumentException("cannot change the writer"); } super.setWriter(writer); }
/** Prepares the appender for use. */ public void activateOptions() { if (follow) { if (target.equals(SYSTEM_ERR)) { setWriter(createWriter(new SystemErrStream())); } else { setWriter(createWriter(new SystemOutStream())); } } else { if (target.equals(SYSTEM_ERR)) { setWriter(createWriter(unwrap(System.err))); } else { setWriter(createWriter(unwrap(System.out))); } } super.activateOptions(); }
/** The WriterAppender requires a layout. Hence, this method returns <code>true</code>. */ public boolean requiresLayout() { return appender.requiresLayout(); }
/** * Sets the Writer where the log output will go. The specified Writer must be opened by the user * and be writable. * * <p>The <code>java.io.Writer</code> will be closed when the appender instance is closed. * * <p><b>WARNING:</b> Logging to an unopened Writer will fail. * * <p> * * @param writer An already opened Writer. */ public synchronized void setWriter(Writer writer) { appender.setWriter(writer); }
/** Returns the layout of this appender. The value may be null. */ public Layout getLayout() { return appender.getLayout(); }
/** * Set the threshold level. All log events with lower level than the threshold level are ignored * by the appender. * * <p>In configuration files this option is specified by setting the value of the <b>Threshold</b> * option to a level string, such as "DEBUG", "INFO" and so on. * * @since 0.8.3 */ public void setThreshold(Priority threshold) { appender.setThreshold(threshold); }
/** * Clear the filters chain. * * @since 0.9.0 */ public void clearFilters() { appender.clearFilters(); }
/** * Set the layout for this appender. Note that some appenders have their own (fixed) layouts or do * not use one. For example, the {@link org.apache.log4j.net.SocketAppender} ignores the layout * set here. */ public void setLayout(Layout layout) { appender.setLayout(layout); }
/** Set the name of this Appender. */ public void setName(String name) { super.setName(name); appender.setName(name); }
/** * Set the {@link ErrorHandler} for this Appender. * * @since 0.9.0 */ public synchronized void setErrorHandler(ErrorHandler eh) { appender.setErrorHandler(eh); }
/** * Check whether the message level is below the appender's threshold. If there is no threshold * set, then the return value is always <code>true</code>. */ public boolean isAsSevereAsThreshold(Priority priority) { return appender.isAsSevereAsThreshold(priority); }
/** * Returns this appenders threshold level. See the {@link #setThreshold} method for the meaning of * this option. * * @since 1.1 */ public Priority getThreshold() { return appender.getThreshold(); }
@Override public void activateOptions() { appender.activateOptions(); super.activateOptions(); }
/** * If the <b>ImmediateFlush</b> option is set to <code>true</code>, the appender will flush at the * end of each write. This is the default behavior. If the option is set to <code>false</code>, * then the underlying stream can defer writing to physical medium to a later time. * * <p>Avoiding the flush operation at the end of each append results in a performance gain of 10 * to 20 percent. However, there is safety tradeoff involved in skipping flushing. Indeed, when * flushing is skipped, then it is likely that the last few log events will not be recorded on * disk when the application exits. This is a high price to pay even for a 20% performance gain. */ public void setImmediateFlush(boolean value) { appender.setImmediateFlush(value); }
/** * Add a filter to end of the filter list. * * @since 0.9.0 */ public void addFilter(Filter newFilter) { appender.addFilter(newFilter); }
/** Returns value of the <b>ImmediateFlush</b> option. */ public boolean getImmediateFlush() { return appender.getImmediateFlush(); }
/** * Return the currently set {@link ErrorHandler} for this Appender. * * @since 0.9.0 */ public ErrorHandler getErrorHandler() { return appender.getErrorHandler(); }
/** * Close this appender instance. The underlying stream or writer is also closed. * * <p>Closed appenders cannot be reused. * * @see #setWriter * @since 0.8.4 */ public synchronized void close() { super.close(); appender.close(); }
@Override public void activateOptions() { super.setWriter(writer); }
public String getEncoding() { return appender.getEncoding(); }
public TelemetryEventAppender() { // Hardcoding pattern because should not be under host application control super.setLayout(new PatternLayout(PATTERN)); }
public void setEncoding(String value) { appender.setEncoding(value); }
/** {@inheritDoc} */ protected final void closeWriter() { if (follow) { super.closeWriter(); } }
/** * Returns the head Filter. * * @since 1.1 */ public Filter getFilter() { return appender.getFilter(); }