0

I am new to the logging frameworks in java. My code doesn't have any configuration xml file for logback. code is:

public void initilizeLogging(final String logName) {
        final Logger log = lc.getLogger(logName);
        log.setLevel(this.logLevel);

        setupFileLogging(log, this.lc);
    }

private void setupFileLogging(final Logger log, final LoggerContext loggerContext) {
        rollingFileAppender = new RollingFileAppender<ILoggingEvent>();
        rollingFileAppender.setFile(this.logFilePath);
      // other settings here..
        rollingpolicy = new SizeAndTimeBasedRollingPolicy<ILoggingEvent>();
        rollingFileAppender.setRollingPolicy(rollingpolicy);

        log.addAppender(rollingFileAppender);
}

There is no ConsoleAppender is configured, but still I see that the logs are written both to file and the console. How can I stop the logs written to the console? Or where should I look for the problem?

pavan kumar
  • 101
  • 7

1 Answers1

0

I was able solve this issue by setting: logger.setAdditive(false);

Found the answer here: What is the result of making log4j additivity equals to true or false? How to disable Logback output to console programmatically but append to file

pavan kumar
  • 101
  • 7