use of org.apache.airavata.common.logging.kafka.KafkaAppender in project airavata by apache.
the class ServerMain method main.
// private static void addSecondaryShutdownHook(){
// Runtime.getRuntime().addShutdownHook(new Thread(){
// @Override
// public void run() {
// System.out.print("Graceful shutdown attempt is still active. Do you want to exit instead? (y/n)");
// String command=System.console().readLine().trim().toLowerCase();
// if (command.equals("yes") || command.equals("y")){
// System.exit(1);
// }
// }
// });
// }
public static void main(String[] args) throws ParseException, IOException, AiravataException {
ServerSettings.mergeSettingsCommandLineArgs(args);
ServerSettings.setServerRoles(ApplicationSettings.getSetting(SERVERS_KEY, "all").split(","));
if (ServerSettings.isEnabledKafkaLogging()) {
final ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
if (iLoggerFactory instanceof LoggerContext) {
final KafkaAppender kafkaAppender = new KafkaAppender(ServerSettings.getKafkaBrokerList(), ServerSettings.getKafkaTopicPrefix());
kafkaAppender.setContext((LoggerContext) iLoggerFactory);
kafkaAppender.setName("kafka-appender");
kafkaAppender.clearAllFilters();
kafkaAppender.start();
// Until AIRAVATA-2073 filter org.apache.kafka logs
((LoggerContext) iLoggerFactory).getLogger("org.apache.airavata").addAppender(kafkaAppender);
((LoggerContext) iLoggerFactory).getLogger("org.apache.zookeeper").addAppender(kafkaAppender);
((LoggerContext) iLoggerFactory).getLogger("org.apache.derby").addAppender(kafkaAppender);
((LoggerContext) iLoggerFactory).getLogger("org.apache.commons").addAppender(kafkaAppender);
((LoggerContext) iLoggerFactory).getLogger("org.apache.thrift").addAppender(kafkaAppender);
((LoggerContext) iLoggerFactory).getLogger("com").addAppender(kafkaAppender);
((LoggerContext) iLoggerFactory).getLogger("net").addAppender(kafkaAppender);
} else {
logger.warn("Kafka logging is enabled but cannot find logback LoggerContext, found", iLoggerFactory.getClass().toString());
throw new AiravataException("Kafka logging is enabled but cannot find logback LoggerContext");
}
} else {
logger.info("Kafka logging is disabled in airavata server configurations");
}
CommandLineParameters commandLineParameters = StringUtil.getCommandLineParser(args);
if (commandLineParameters.getArguments().contains(STOP_COMMAND_STR)) {
performServerStopRequest(commandLineParameters);
} else {
AiravataZKUtils.startEmbeddedZK(cnxnFactory);
performServerStart(args);
}
}
Aggregations