private static void setupLogging ( Config config ) throws IOException { String systemConfigFilename = Context . systemConfigFile ( config ) ; SystemConfig systemConfig = SystemConfig . newBuilder ( true ) . putAll ( systemConfigFilename , true ) . build ( ) ; // Init the logging setting and redirect the stdout and stderr to logging // For now we just set the logging level as INFO; later we may accept an argument to set it. Level loggingLevel = Level . INFO ; if ( Context . verbose ( config ) . booleanValue ( ) ) { loggingLevel = Level . FINE ; } // TODO(mfu): The folder creation may be duplicated with heron-executor in future // TODO(mfu): Remove the creation in future if feasible String loggingDir = systemConfig . getHeronLoggingDirectory ( ) ; if ( ! FileUtils . isDirectoryExists ( loggingDir ) ) { FileUtils . createDirectory ( loggingDir ) ; } // Log to file LoggingHelper . loggerInit ( loggingLevel , true ) ; // TODO(mfu): Pass the scheduler id from cmd String processId = String . format ( "%s-%s-%s" , "heron" , Context . topologyName ( config ) , "scheduler" ) ; LoggingHelper . addLoggingHandler ( LoggingHelper . getFileHandler ( processId , loggingDir , true , systemConfig . getHeronLoggingMaximumSize ( ) , systemConfig . getHeronLoggingMaximumFiles ( ) ) ) ; LOG . info ( "Logging setup done." ) ; }
Set up logging based on the Config