Java 类org.springframework.boot.logging.LoggingApplicationListener 实例源码

项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) throws InterruptedException {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    builder.run(args);

    LOGGER.info("hi-log-log4j2 start successfully");

    String a = "哈哈";
    while (true) {
        LOGGER.info("i am test, {}", a);
        Thread.sleep(1000);
    }
}
项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    ConfigurableApplicationContext context = builder.run(args);
    LOGGER.info("collector trace start successfully");

    KafkaConsumer kafkaConsumer = (KafkaConsumer<byte[], String>) context.getBean("kafkaConsumer");
    Task task = (Task) context.getBean("rpcTraceTask");

    // 优雅停止项目
    Runtime.getRuntime().addShutdownHook(new ShutdownHookRunner(kafkaConsumer, task));
    task.doTask();
}
项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    ConfigurableApplicationContext context = builder.run(args);
    LOGGER.info("collector indexer start successfully");

    KafkaConsumer kafkaConsumer = (KafkaConsumer<byte[], String>) context.getBean("kafkaConsumer");
    Task task = (Task) context.getBean("indexerTask");

    // 优雅停止项目
    Runtime.getRuntime().addShutdownHook(new ShutdownHookRunner(kafkaConsumer, task));
    task.doTask();
}
项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    ConfigurableApplicationContext context = builder.run(args);
    LOGGER.info("collector backup start successfully");

    KafkaConsumer kafkaConsumer = (KafkaConsumer<byte[], String>) context.getBean("kafkaConsumer");
    Task task = (Task) context.getBean("backupTask");

    // 优雅停止项目
    Runtime.getRuntime().addShutdownHook(new ShutdownHookRunner(kafkaConsumer, task));
    task.doTask();
}
项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    ConfigurableApplicationContext context = builder.run(args);
    LOGGER.info("collector metrics start successfully");

    KafkaConsumer kafkaConsumer = (KafkaConsumer<byte[], String>) context.getBean("kafkaConsumer");
    Task task = (Task) context.getBean("metricsTask");

    // 优雅停止项目
    Runtime.getRuntime().addShutdownHook(new ShutdownHookRunner(kafkaConsumer, task));
    task.doTask();
}
项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    builder.run(args);

    LOGGER.info("服务C start successfully");

    // 优雅停止项目
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            LOGGER.info("try to stop the system");
            synchronized (Launcher.class) {
                RUNNING = false;
                Launcher.class.notify();
            }
        }
    });

    synchronized (Launcher.class) {
        while (RUNNING) {
            try {
                Launcher.class.wait();
            } catch (InterruptedException e) {
                LOGGER.error("wait error");
                e.printStackTrace();
            }
        }
    }
}
项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    builder.run(args);

    LOGGER.info("服务B start successfully");

    // 优雅停止项目
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            LOGGER.info("try to stop the system");
            synchronized (Launcher.class) {
                RUNNING = false;
                Launcher.class.notify();
            }
        }
    });

    synchronized (Launcher.class) {
        while (RUNNING) {
            try {
                Launcher.class.wait();
            } catch (InterruptedException e) {
                LOGGER.error("wait error");
                e.printStackTrace();
            }
        }
    }
}
项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    builder.run(args);

    LOGGER.info("服务E start successfully");

    // 优雅停止项目
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            LOGGER.info("try to stop the system");
            synchronized (Launcher.class) {
                RUNNING = false;
                Launcher.class.notify();
            }
        }
    });

    synchronized (Launcher.class) {
        while (RUNNING) {
            try {
                Launcher.class.wait();
            } catch (InterruptedException e) {
                LOGGER.error("wait error");
                e.printStackTrace();
            }
        }
    }
}
项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    builder.run(args);

    LOGGER.info("服务D start successfully");

    // 优雅停止项目
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            LOGGER.info("try to stop the system");
            synchronized (Launcher.class) {
                RUNNING = false;
                Launcher.class.notify();
            }
        }
    });

    synchronized (Launcher.class) {
        while (RUNNING) {
            try {
                Launcher.class.wait();
            } catch (InterruptedException e) {
                LOGGER.error("wait error");
                e.printStackTrace();
            }
        }
    }
}
项目:SkyEye    文件:Application.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    builder.run(args);

    LOGGER.info("接口A start successfully");
}
项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    builder.run(args);
    LOGGER.info("alarm start successfully");

    // 优雅停止项目
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            LOGGER.info("try to stop the system");
            synchronized (Launcher.class) {
                RUNNING = false;
                Launcher.class.notify();
            }
        }
    });

    synchronized (Launcher.class) {
        while (RUNNING) {
            try {
                Launcher.class.wait();
            } catch (InterruptedException e) {
                LOGGER.error("wait error");
                e.printStackTrace();
            }
        }
    }
}
项目:SkyEye    文件:Application.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    builder.run(args);

    LOGGER.info("web start successfully");
}
项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    builder.run(args);
    LOGGER.info("monitor start successfully");

    // 优雅停止项目
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            LOGGER.info("try to stop the system");
            synchronized (Launcher.class) {
                RUNNING = false;
                Launcher.class.notify();
            }
        }
    });

    synchronized (Launcher.class) {
        while (RUNNING) {
            try {
                Launcher.class.wait();
            } catch (InterruptedException e) {
                LOGGER.error("wait error");
                e.printStackTrace();
            }
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RemoteSpringApplication.java   
private Collection<ApplicationListener<?>> getListeners() {
    List<ApplicationListener<?>> listeners = new ArrayList<ApplicationListener<?>>();
    listeners.add(new AnsiOutputApplicationListener());
    listeners.add(new ConfigFileApplicationListener());
    listeners.add(new ClasspathLoggingApplicationListener());
    listeners.add(new LoggingApplicationListener());
    listeners.add(new RemoteUrlPropertyExtractor());
    return listeners;
}
项目:spring-boot-concourse    文件:RemoteSpringApplication.java   
private Collection<ApplicationListener<?>> getListeners() {
    List<ApplicationListener<?>> listeners = new ArrayList<ApplicationListener<?>>();
    listeners.add(new AnsiOutputApplicationListener());
    listeners.add(new ConfigFileApplicationListener());
    listeners.add(new ClasspathLoggingApplicationListener());
    listeners.add(new LoggingApplicationListener());
    listeners.add(new RemoteUrlPropertyExtractor());
    return listeners;
}
项目:contestparser    文件:RemoteSpringApplication.java   
private Collection<ApplicationListener<?>> getListeners() {
    List<ApplicationListener<?>> listeners = new ArrayList<ApplicationListener<?>>();
    listeners.add(new AnsiOutputApplicationListener());
    listeners.add(new ConfigFileEnvironmentPostProcessor());
    listeners.add(new EnvironmentPostProcessingApplicationListener());
    listeners.add(new ClasspathLoggingApplicationListener());
    listeners.add(new LoggingApplicationListener());
    listeners.add(new RemoteUrlPropertyExtractor());
    return listeners;
}
项目:sdcct    文件:SdcctApplicationConfiguration.java   
public static SdcctApplication buildApplication() {
    ResourceLoader resourceLoader = new DefaultResourceLoader();
    ResourcePatternResolver resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);

    SdcctApplication app = ((SdcctApplication) new SdcctApplicationBuilder(buildSources(resourcePatternResolver)).addCommandLineProperties(false)
        .bannerMode(Mode.OFF).headless(true).resourceLoader(resourceLoader).application());

    app.setPropertySource(buildPropertySource(resourcePatternResolver));

    app.setListeners(
        app.getListeners().stream().filter((appListener -> !appListener.getClass().equals(LoggingApplicationListener.class))).collect(Collectors.toList()));

    return app;
}
项目:crigtt    文件:CrigttApplicationConfiguration.java   
public static CrigttApplication buildApplication() {
    ResourceLoader resourceLoader = new DefaultResourceLoader();

    CrigttApplication app =
        ((CrigttApplication) new CrigttApplicationBuilder(buildApplicationSources(resourceLoader)).addCommandLineProperties(false).showBanner(false)
            .headless(true).resourceLoader(resourceLoader).application());
    app.setListeners(app.getListeners().stream().filter((appListener -> !appListener.getClass().equals(LoggingApplicationListener.class)))
        .collect(Collectors.toList()));

    return app;
}
项目:airsonic    文件:LoggingFileOverrideListener.java   
@Override
public int getOrder() {
    return LoggingApplicationListener.DEFAULT_ORDER - 1;
}
项目:SkyEye    文件:Launcher.java   
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    ConfigurableApplicationContext context = builder.run(args);
    LOGGER.info("log-generator start successfully");

    GenerateLogService logService = context.getBean(GenerateLogService.class);
    logService.generateCoverLog();



    // 优雅停止项目
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            LOGGER.info("try to stop the system");
            synchronized (Launcher.class) {
                RUNNING = false;
                Launcher.class.notify();
            }
        }
    });

    synchronized (Launcher.class) {
        while (RUNNING) {
            try {
                Launcher.class.wait();
            } catch (InterruptedException e) {
                LOGGER.error("wait error");
                e.printStackTrace();
            }
        }
    }
}