@Test public void appenderNameIsSet() throws Exception { final Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); final SyslogAppenderFactory appenderFactory = new SyslogAppenderFactory(); final Appender<ILoggingEvent> appender = appenderFactory.build( root.getLoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory()); assertThat(appender.getName()).isEqualTo("async-syslog-appender"); }
public static void main(String[] args) throws Exception { // See : http://patorjk.com/software/taag/#p=display&f=Slant&t=Flamingo%20Collector System.out.println( " _ __ ____ _ _ _ _____ \n" + " | |/ /__ ____ / __ \\_________ _ __(_)____(_)___ ____ (_)___ ____ _ / ___/___ ______ _____ _____\n" + " | / _ \\/ __ \\ / /_/ / ___/ __ \\ | / / / ___/ / __ \\/ __ \\/ / __ \\/ __ `/ \\__ \\/ _ \\/ ___/ | / / _ \\/ ___/\n" + " / / __/ / / / / ____/ / / /_/ / |/ / (__ ) / /_/ / / / / / / / / /_/ / ___/ / __/ / | |/ / __/ / \n" + "/_/|_\\___/_/ /_/ /_/ /_/ \\____/|___/_/____/_/\\____/_/ /_/_/_/ /_/\\__, / /____/\\___/_/ |___/\\___/_/ \n" + " /____/ \n"); //////////////////////////////////////////////////////////////////////////////////// StringBuilder builder = new StringBuilder(); printHeader(builder, "Application Information"); Properties appProps = new Properties(); Properties systemProperties = System.getProperties(); appProps.put( "Java Version", systemProperties.getProperty("java.version", UNKNOWN) + " - " + systemProperties.getProperty("java.vendor", UNKNOWN)); appProps.put("Current Working Directory", systemProperties.getProperty("user.dir", UNKNOWN)); print(builder, appProps); Properties memPros = new Properties(); final Runtime rt = Runtime.getRuntime(); final long maxMemory = rt.maxMemory() / MEGA_BYTES; final long totalMemory = rt.totalMemory() / MEGA_BYTES; final long freeMemory = rt.freeMemory() / MEGA_BYTES; final long usedMemory = totalMemory - freeMemory; memPros.put("Maximum Allowable Memory", maxMemory + "MB"); memPros.put("Total Memory", totalMemory + "MB"); memPros.put("Free Memory", freeMemory + "MB"); memPros.put("Used Memory", usedMemory + "MB"); print(builder, memPros); printHeader(builder, "Java System Properties"); Properties sysProps = new Properties(); for (final Map.Entry<Object, Object> entry : systemProperties.entrySet()) { sysProps.put(entry.getKey(), entry.getValue()); } print(builder, sysProps); printHeader(builder, "System Environments"); Map<String, String> getenv = System.getenv(); Properties envProps = new Properties(); Set<String> strings = getenv.keySet(); for (String key : strings) { String message = getenv.get(key); envProps.put(key, message); } print(builder, envProps); System.out.println(builder.toString()); //////////////////////////////////////////////////////////////////////////////////// NativeLoader.loadSigarNative(); //////////////////////////////////////////////////////////////////////////////////// SpringApplication app = new SpringApplication(Application.class); app.setShowBanner(false); ApplicationContext ctx = app.run(args); try { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); for (Logger LOGGER : context.getLoggerList()) { if (LOGGER instanceof ch.qos.logback.classic.Logger) { ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) LOGGER; for (Iterator<Appender<ILoggingEvent>> index = logbackLogger.iteratorForAppenders(); index.hasNext(); ) { Appender<ILoggingEvent> appender = index.next(); if ("FILE".equals(appender.getName()) && appender instanceof ch.qos.logback.core.rolling.RollingFileAppender) { ch.qos.logback.core.rolling.RollingFileAppender logbackAppender = (ch.qos.logback.core.rolling.RollingFileAppender) appender; logger.info("Log file is {}", logbackAppender.getFile()); } } } } } catch (Exception ex) { } }