public static Appender<ILoggingEvent> wrap(Appender<ILoggingEvent> delegate) { final AsyncAppender appender = new AsyncAppender(delegate); appender.start(); return appender; }
@Valid @NotNull @JsonProperty("logging") private LoggingFactory loggingFactory = new LoggingFactory(); public LoggingFactory getLoggingFactory() { return loggingFactory; }
public LogFormatter(LoggerContext context, TimeZone timeZone) { super(); setOutputPatternAsHeader(false); getDefaultConverterMap().put("ex", PrefixedThrowableProxyConverter.class.getName()); getDefaultConverterMap().put("xEx", PrefixedExtendedThrowableProxyConverter.class.getName()); // This pattern allows time, log level then thread to be quickly located making unusual // activity such as WARN and ERROR stand out setPattern("[%d{ISO8601," + timeZone.getID() + "}] %-5level [%thread] %logger{16} - %msg %xEx%n"); setContext(context); }
public void configure() { hijackJDKLogging(); final Logger root = configureLevels(); final LoggingConfiguration.ConsoleConfiguration console = config.getConsoleConfiguration(); if (console.isEnabled()) { root.addAppender(AsyncAppender.wrap( LogbackFactory.buildConsoleAppender( console, root.getLoggerContext(), console.getLogFormat()))); } final LoggingConfiguration.FileConfiguration file = config.getFileConfiguration(); if (file.isEnabled()) { root.addAppender(AsyncAppender.wrap( LogbackFactory.buildFileAppender( file, root.getLoggerContext(), file.getLogFormat()))); } final LoggingConfiguration.SyslogConfiguration syslog = config.getSyslogConfiguration(); if (syslog.isEnabled()) { root.addAppender(AsyncAppender.wrap( LogbackFactory.buildSyslogAppender( syslog, root.getLoggerContext(), name, syslog.getLogFormat()))); } }
public static ConsoleAppender<ILoggingEvent> buildConsoleAppender( LoggingConfiguration.ConsoleConfiguration console, LoggerContext context, String logFormat) { final LogFormatter formatter = new LogFormatter(context, console.getTimeZone()); if (logFormat != null) { formatter.setPattern(logFormat); } formatter.start(); final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>(); appender.setContext(context); appender.setLayout(formatter); addThresholdFilter(appender, console.getThreshold()); appender.start(); return appender; }
public static void bootstrap() { // Initially configure for DEBUG console logging final LoggingConfiguration.ConsoleConfiguration console = new LoggingConfiguration.ConsoleConfiguration(); console.setEnabled(true); console.setTimeZone(TimeZone.getDefault()); console.setThreshold(Level.DEBUG); final Logger root = getCleanRoot(); root.addAppender(LogbackFactory.buildConsoleAppender( console, root.getLoggerContext(), null )); final LoggingConfiguration.FileConfiguration file = new LoggingConfiguration.FileConfiguration(); root.addAppender(LogbackFactory.buildFileAppender(file, root.getLoggerContext(), null)); // Add this to indicate that logging has bootstrapped with synchronous default settings log.info("LoggingFactory bootstrap completed."); }
/** * <p>Initialises the core services, and can act as an independent starting point for headless operations</p> * * @param args Any command line arguments */ public static void main(String[] args) { // Order is important here applicationEventService = new ApplicationEventService(); environmentCheckingService = new EnvironmentCheckingService(); if (configurationService == null) { bootstrap(); } // Configure logging now that we have a configuration new LoggingFactory(Configurations.currentConfiguration.getLogging(), "MultiBit HD").configure(); // Start environment checking service environmentCheckingService.start(); // Start application event service applicationEventService.start(); // Create Payment Protocol service (once configuration identifies the network parameters) paymentProtocolService = new PaymentProtocolService(BitcoinNetwork.current().get()); paymentProtocolService.start(); // Configure Bitcoinj Threading.UserThread.WARNING_THRESHOLD = Integer.MAX_VALUE; }
void subjoinThrowableProxy(StringBuilder buf, IThrowableProxy tp) { subjoinFirstLine(buf, tp); buf.append(CoreConstants.LINE_SEPARATOR); final StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); final int commonFrames = tp.getCommonFrames(); int maxIndex = stepArray.length; if (commonFrames > 0) { maxIndex -= commonFrames; } for (int i = 0; i < maxIndex; i++) { final String string = stepArray[i].toString(); buf.append(PREFIX); buf.append(string); extraData(buf, stepArray[i]); // allow other data to be added buf.append(CoreConstants.LINE_SEPARATOR); } if (commonFrames > 0) { buf.append("!... ").append(tp.getCommonFrames()).append( " common frames omitted").append(CoreConstants.LINE_SEPARATOR); } }
private void subjoinFirstLine(StringBuilder buf, IThrowableProxy tp) { final int commonFrames = tp.getCommonFrames(); if (commonFrames > 0) { buf.append(CoreConstants.CAUSED_BY); } subjoinExceptionMessage(buf, tp); }
@Override protected String throwableProxyToString(IThrowableProxy tp) { final StringBuilder buf = new StringBuilder(32); IThrowableProxy currentThrowable = tp; while (currentThrowable != null) { subjoinThrowableProxy(buf, currentThrowable); currentThrowable = currentThrowable.getCause(); } return buf.toString(); }
private AsyncAppender(Appender<ILoggingEvent> delegate) { this.delegate = delegate; this.queue = Queues.newLinkedBlockingQueue(); this.batch = Lists.newArrayListWithCapacity(BATCH_SIZE); this.dispatcher = THREAD_FACTORY.newThread(this); setContext(delegate.getContext()); }
LoggingFactory.bootstrap();
public static SyslogAppender buildSyslogAppender( LoggingConfiguration.SyslogConfiguration syslog, LoggerContext context, String name, String logFormat) { final SyslogAppender appender = new SyslogAppender(); appender.setName(name); appender.setContext(context); appender.setSyslogHost(syslog.getHost()); appender.setFacility(syslog.getFacility().toString()); addThresholdFilter(appender, syslog.getThreshold()); if (logFormat != null) { appender.setSuffixPattern(logFormat); } appender.start(); return appender; }
final LogFormatter formatter = new LogFormatter(context, fileConfiguration.getTimeZone()); formatter.setPattern(logFormat); formatter.start(); appender.setEncoder(encoder); addThresholdFilter(appender, fileConfiguration.getThreshold());