public static void main(final String[] args) { System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087: explicitly enable // System.out.println(System.getProperty("java.class.path")); final String config = args.length == 0 ? "target/test-classes/log4j2-180.xml" : args[0]; try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config)) { LOG.fatal("Fatal message."); LOG.error("Error message."); LOG.warn("Warning message."); LOG.info("Information message."); LOG.debug("Debug message."); LOG.trace("Trace message."); try { throw new NullPointerException(); } catch (final Exception e) { LOG.error("Error message.", e); LOG.catching(Level.ERROR, e); } } }
public static void main(final String[] args) { System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087: explicitly enable // System.out.println(System.getProperty("java.class.path")); final String config = args.length == 0 ? "target/test-classes/log4j2-272.xml" : args[0]; try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config)) { LOG.fatal("Fatal message."); LOG.error("Error message."); LOG.warn("Warning message."); LOG.info("Information message."); LOG.debug("Debug message."); LOG.trace("Trace message."); try { throw new NullPointerException(); } catch (final Exception e) { LOG.error("Error message.", e); LOG.catching(Level.ERROR, e); } LOG.warn("this is ok \n And all \n this have only\t\tblack colour \n and here is colour again?"); LOG.info("Information message."); } }
@Test public void catching() { try { throw new NullPointerException(); } catch (final Exception e) { logger.catching(e); } final List<LogEvent> events = app.getEvents(); assertEquals("Incorrect number of events. Expected 1, actual " + events.size(), 1, events.size()); }
public static void main(final String[] args) { System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087: explicitly enable // System.out.println(System.getProperty("java.class.path")); final String config = args.length == 0 ? "target/test-classes/log4j2-319.xml" : args[0]; try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config)) { LOG.fatal("Fatal message."); LOG.error("Error message."); LOG.warn("Warning message."); LOG.info("Information message."); LOG.debug("Debug message."); LOG.trace("Trace message."); try { throw new NullPointerException(); } catch (final Exception e) { LOG.error("Error message.", e); LOG.catching(Level.ERROR, e); } LOG.warn("this is ok \n And all \n this have only\t\tblack colour \n and here is colour again?"); LOG.info("Information message."); } }
@Test public void catching() { try { throw new NullPointerException(); } catch (final Exception e) { logger.catching(e); } final List<LogEvent> events = app.getEvents(); assertEventCount(events, 1); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { LOGGER.catching(cause); ctx.close(); } }
public void shutdown() { this.executorService.shutdown(); try { this.executorService.awaitTermination(3, TimeUnit.SECONDS); } catch (InterruptedException e) { log.catching(e); } }
private synchronized void closeIndexWriter() { if (nonNull(this.indexWriter)) { try { this.indexWriter.close(); } catch (IOException e) { log.catching(e); } } this.indexWriter = null; }
public static File getInstalledPath() { try { return new File( Config.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()); } catch (URISyntaxException e) { log.catching(e); throw new RuntimeException(e); } }
public static String toString(Document doc, String indent, XmlWriter.Feature... features) { try (StringWriter writer = new StringWriter()) { save(doc, writer, indent, features); return writer.toString(); } catch (final IOException e) { LOGGER.catching(e); } return null; }
private synchronized void closeIndexSearcher() { if (nonNull(this.indexSearcher)) { try { this.indexSearcher.close(); } catch (IOException e) { log.catching(e); } } this.indexSearcher = null; }
@Override public void stopSending() { try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.unregisterMBean(new ObjectName("loghub:type=sender,servicename=" + getName() + ",name=connectionsPool")); } catch (MalformedObjectNameException | MBeanRegistrationException | InstanceNotFoundException e) { logger.error("Failed to unregister mbeam: " + Helpers.resolveThrowableException(e), e); logger.catching(Level.DEBUG, e); } super.stopSending(); }
private void requestAsyncStore(StoreRequest req) { if (isNull(req.getStorable()) && isNull(req.getStorables())) { throw new IllegalArgumentException("require obj or objects"); } try { this.blockingQueue.put(req); this.runWorker(); } catch (InterruptedException e) { log.catching(e); } }
@Override public void close() { try { snmp.close(); } catch (IOException e1) { logger.error("Failure on snmp close: {}", e1); logger.catching(e1); } super.close(); }
@Override public void onChannelInitializeException(ChannelHandlerContext arg0, Throwable error) { logger.fatal("Beats initialization exception: {}", Helpers.resolveThrowableException(error)); logger.catching(Level.DEBUG, error); }
@Override public void exception(ChannelHandlerContext ctx, Throwable cause) { logger.error("Unable to process query: {}", Helpers.resolveThrowableException(cause)); logger.catching(Level.DEBUG, cause); ctx.pipeline().addAfter("HttpObjectAggregator", "FatalErrorHandler", getFatalErrorHandler()); }
@Override public void close() { try { this.closeIndexSearcher(); this.closeIndexWriter(); this.directory.close(); } catch (Throwable e) { log.catching(e); } } }
protected static void print(Node node) { try { OUT.println("====================="); XmlDataWriter.print(node, false, OUT, " ", false, XmlWriter.Feature.APPEND_FINAL_EOL); OUT.println(); } catch (final IOException e) { LOGGER.catching(e); } }
@Test public void testConvertPathToClass1() throws Exception { File f = new File(project.getProjectRootPath(), "./src/main/java/meghanada/session/Session.java") .getCanonicalFile(); try { Optional<String> s = FileUtils.convertPathToClass(project.getAllSources(), f); log.info("{}", s); } catch (IOException e) { log.catching(e); } }