Package org.apache.log4j

Examples of org.apache.log4j.RollingFileAppender


        File backUpFile = File.createTempFile(file.getName() + ".", ".1." + LogFileHelper.GZIP_EXTENSION);
        _appendersFiles.put(QpidCompositeRollingAppender.class.getSimpleName(), Arrays.asList(file, backUpFile));

        FileAppender fileAppender = new FileAppender();
        DailyRollingFileAppender dailyRollingFileAppender = new DailyRollingFileAppender();
        RollingFileAppender rollingFileAppender = new RollingFileAppender();
        ExternallyRolledFileAppender externallyRolledFileAppender = new ExternallyRolledFileAppender();
        QpidCompositeRollingAppender qpidCompositeRollingAppender = new QpidCompositeRollingAppender();
        qpidCompositeRollingAppender.setbackupFilesToPath(_compositeRollingAppenderBackupFolder.getPath());

        _appenders = new ArrayList<Appender>();
View Full Code Here


    }
    Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
    // disable logging while the cluster startup preps files
    logger.setLevel(Level.OFF);
    PatternLayout layout = new PatternLayout("%m%n");
    RollingFileAppender appender = new RollingFileAppender(layout, auditLogFile);
    logger.addAppender(appender);
  }
View Full Code Here

      file.delete();
    }
    Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
    logger.setLevel(Level.INFO);
    PatternLayout layout = new PatternLayout("%m%n");
    RollingFileAppender appender = new RollingFileAppender(layout, auditLogFile);
    logger.addAppender(appender);
  }
View Full Code Here

        }

        PatternLayout layout = new PatternLayout(pattern);
        layout.activateOptions();

        RollingFileAppender newAppender = null;
        try {
            newAppender = new RollingFileAppender(layout, logFile, true);
        } catch (IOException e) {
            logFatal(e, Debug.class.getName());
        }

        if (newAppender != null) {
            if (backupIdx > 0) {
                newAppender.setMaxBackupIndex(backupIdx);
            }
            if (maxSize > 0) {
                newAppender.setMaximumFileSize(maxSize);
            }
            newAppender.setThreshold(Level.DEBUG);
            newAppender.activateOptions();
            newAppender.setName(name);
        }

        return newAppender;
    }
View Full Code Here

            appender = (Appender)filesTable.get(path);
            if (appender == null)
            {
                try
                {
                    appender = new RollingFileAppender(layout, path, true);
                    ((RollingFileAppender)appender)
                        .setMaxBackupIndex(loggingConfig.getBackupFiles());
                    //finding file size
                    if (loggingConfig.getFileSize() > -1)
                    {
View Full Code Here

      file.delete();
    }
    Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
    logger.setLevel(Level.INFO);
    PatternLayout layout = new PatternLayout("%m%n");
    RollingFileAppender appender = new RollingFileAppender(layout, auditLogFile);
    logger.addAppender(appender);
  }
View Full Code Here

    //make sure we reset the file
    if (appender != null)
    {
      try
      {
        RollingFileAppender fileAppender = RollingFileAppender.class.cast(appender);
        //reset the logfile if necessary
        if (!fileAppender.getFile().equals(logFile_))
        {
          logger.info("Reseting general log file destination. Old file: " + fileAppender.getFile()
                  + ". New file: " + logFile_);
          fileAppender.setFile(logFile_);
          fileAppender.activateOptions();
        }
      }
      catch (Exception ex)
      {
        logger.warn("Can not verify the current general log appender. "
                + "It will deleted and new one created with default setting")
        //delete the appender and recreate a new one
        logger.removeAppender(appender);
        appender = null;
      }
    }
    // create a new appender with default setting!
    if (null == appender)
    {
      RollingFileAppender fileAppender = new RollingFileAppender();
      fileAppender.setName("DataStoreAppender");
      fileAppender.setMaxFileSize("100KB");
      fileAppender.setMaxBackupIndex(10);
      PatternLayout layout = new PatternLayout("%-5p %d{dd MMM yyyy HH:mm:ss} [%x] %m%n");
      fileAppender.setLayout(layout);
      fileAppender.setFile(logFile_);
      fileAppender.activateOptions();
      // add into the logger
      logger.addAppender(fileAppender);
    }
   
    return logger;
View Full Code Here

    //make sure we reset the file
    if (appender != null)
    {
      try
      {
        RollingFileAppender fileAppender = RollingFileAppender.class.cast(appender);
        //reset the logfile if necessary
        if (!fileAppender.getFile().equals(commLogFile_))
        {
          logger.info("Reseting comm log file destination. Old file: " + fileAppender.getFile()
                  + ". New file: " + commLogFile_);
          fileAppender.setFile(commLogFile_);
          fileAppender.activateOptions();
        }
      }
      catch (Exception ex)
      {
        logger.warn("Can not verify the current comm log appender. "
                + "It will deleted and new one created with default setting")
        //delete the appender and recreate a new one
        logger.removeAppender(appender);
        appender = null;
      }
    }
    // create a new appender with default setting!
    if (null == appender)
    {
      RollingFileAppender fileAppender = new RollingFileAppender();
      fileAppender.setName("DataStoreCommAppender");
      fileAppender.setMaxFileSize("100KB");
      fileAppender.setMaxBackupIndex(10);
      PatternLayout layout = new PatternLayout("%-5p %d{dd MMM yyyy HH:mm:ss} [%x] %m%n");
      fileAppender.setLayout(layout);
      fileAppender.setFile(commLogFile_);
      fileAppender.activateOptions();
      // add into the logger
      logger.addAppender(fileAppender);
    }
   
    return logger;
View Full Code Here

        }

        PatternLayout layout = new PatternLayout(pattern);
        layout.activateOptions();

        RollingFileAppender newAppender = null;
        try {
            newAppender = new RollingFileAppender(layout, logFile, true);
        } catch (IOException e) {
            logFatal(e, Debug.class.getName());
        }

        if (newAppender != null) {
            if (backupIdx > 0) {
                newAppender.setMaxBackupIndex(backupIdx);
            }
            if (maxSize > 0) {
                newAppender.setMaximumFileSize(maxSize);
            }
            newAppender.setThreshold(Level.DEBUG);
            newAppender.activateOptions();
            newAppender.setName(name);
        }

        return newAppender;
    }
View Full Code Here

   
    //we do not have any file appender.
    if (!hasFileAppender)
    {
      //create a new one with default setting!
      RollingFileAppender appender = new RollingFileAppender();
      appender.setName(DEF_LOG_APPENDER);
      appender.setMaxFileSize(DEF_APPENDER_MAXFILESIZE);
      appender.setMaxBackupIndex(DEF_APPENDER_MAXBACKUP);
      PatternLayout layout = new PatternLayout(DEF_APPENDER_PATTERN);
      appender.setLayout(layout);
      appender.setFile(filename);
      appender.activateOptions();
      //add into the logger
      logger.addAppender(appender);
    }
   
    //keep the logfile name
View Full Code Here

TOP

Related Classes of org.apache.log4j.RollingFileAppender

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.