public static Logger createLogger(String name, Level level, String file) {
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    PatternLayoutEncoder ple = new PatternLayoutEncoder();
    ple.setPattern("%date %level [%thread] %logger{10} [%file:%line]%n%msg%n%n");
    ple.setContext(lc);
    ple.start();
    FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>();
    fileAppender.setFile(file);
    fileAppender.setEncoder(ple);
    fileAppender.setAppend(false);
    fileAppender.setContext(lc);
    fileAppender.start();
    logger = (Logger) LoggerFactory.getLogger(name);
    logger.detachAndStopAllAppenders(); // detach console (doesn't seem to work)
    logger.addAppender(fileAppender); // attach file appender
    logger.setLevel(level);
    logger.setAdditive(true); // set to true if root should log too

    return logger;
  }
public static Logger createLogger(String name, Level level, String file) {
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    PatternLayoutEncoder ple = new PatternLayoutEncoder();
    ple.setPattern("%date %level [%thread] %logger{10} [%file:%line]%n%msg%n%n");
    ple.setContext(lc);
    ple.start();
    FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>();
    fileAppender.setFile(file);
    fileAppender.setEncoder(ple);
    fileAppender.setAppend(false);
    fileAppender.setContext(lc);
    fileAppender.start();
    logger = (Logger) LoggerFactory.getLogger(name);
    logger.detachAndStopAllAppenders(); 
    logger.addAppender(fileAppender); 
    logger.setLevel(level);
    logger.setAdditive(true); 

    return logger;
  }
public static Logger createLogger ( String name , Level level , String file ) { LoggerContext lc = ( LoggerContext ) LoggerFactory . getILoggerFactory ( ) ; PatternLayoutEncoder ple = new PatternLayoutEncoder ( ) ; ple . setPattern ( "%date %level [%thread] %logger{10} [%file:%line]%n%msg%n%n" ) ; ple . setContext ( lc ) ; ple . start ( ) ; FileAppender < ILoggingEvent > fileAppender = new FileAppender < ILoggingEvent > ( ) ; fileAppender . setFile ( file ) ; fileAppender . setEncoder ( ple ) ; fileAppender . setAppend ( false ) ; fileAppender . setContext ( lc ) ; fileAppender . start ( ) ; logger = ( Logger ) LoggerFactory . getLogger ( name ) ; logger . detachAndStopAllAppenders ( ) ; // detach console (doesn't seem to work) logger . addAppender ( fileAppender ) ; // attach file appender logger . setLevel ( level ) ; logger . setAdditive ( true ) ; // set to true if root should log too return logger ; }
Creates a new logger.

@param name a name for the logger
@param level the logging level for the logger
@param file the file to output all logging to
@return the created logger
Creates a new logger .