@RequestMapping(
     value = "/logs",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public List<LoggerDTO> getList() {
   LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
   return context.getLoggerList().stream().map(LoggerDTO::new).collect(Collectors.toList());
 }
Пример #2
0
  @RequestMapping(value = "/rest/logs", method = RequestMethod.GET, produces = "application/json")
  @Timed
  @ApiIgnore
  public List<LoggerDTO> getList() {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

    List<LoggerDTO> loggers = new ArrayList<LoggerDTO>();
    for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
      loggers.add(new LoggerDTO(logger));
    }
    return loggers;
  }
Пример #3
0
 @RequestMapping(
     value = "/logs",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public List<LoggerDTO> getList() {
   LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
   List<LoggerDTO> loggers = new ArrayList<>();
   for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
     loggers.add(new LoggerDTO(logger));
   }
   return loggers;
 }
  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) {
    }
  }