private void configureDirectToConsoleLoggers ( LoggerContext context , String ... loggerNames ) { RootLoggerConfig config = newRootLoggerConfigBuilder ( ) . setProcessId ( ProcessId . APP ) . setThreadIdFieldPattern ( "" ) . build ( ) ; String logPattern = helper . buildLogPattern ( config ) ; ConsoleAppender < ILoggingEvent > consoleAppender = helper . newConsoleAppender ( context , "CONSOLE" , logPattern ) ; for ( String loggerName : loggerNames ) { Logger consoleLogger = context . getLogger ( loggerName ) ; consoleLogger . setAdditive ( false ) ; consoleLogger . addAppender ( consoleAppender ) ; } }
Setup one or more specified loggers to be non additive and to print to System . out which will be caught by the Main Process and written to sonar . log .