Package org.apache.log4j

Examples of org.apache.log4j.DailyRollingFileAppender


        File d = new File(directory);
        if (!d.isDirectory()) {
            directory = d.getParent() + File.separator;
        }

        DailyRollingFileAppender fa = new DailyRollingFileAppender();
        fa.setName(harvesterName);
        String logfile = directory + "harvester_" + packageType + "_"
                         + harvesterName + "_"
                         + dateFormat.format(new Date(System.currentTimeMillis()))
                         + ".log";
        fa.setFile(logfile);
        fa.setLayout(new PatternLayout("%d{ISO8601} %-5p [%c] - %m%n"));
        fa.setThreshold(log.getThreshold());
        fa.setAppend(true);
        fa.activateOptions();

        log.setAppender(fa);

        return logfile;
    }
View Full Code Here


*
* @version $Revision: 1.3 $ $Date: 2004/03/10 09:59:30 $
*/
public class DailyRollingFileAppenderService extends FileAppenderService {
    public DailyRollingFileAppenderService(ServerInfo serverInfo) {
        super(serverInfo, new DailyRollingFileAppender());
    }
View Full Code Here

*
* @version $Revision: 1.5 $ $Date: 2004/07/12 06:07:50 $
*/
public class DailyRollingFileAppenderService extends FileAppenderService {
    public DailyRollingFileAppenderService(ServerInfo serverInfo) {
        super(serverInfo, new DailyRollingFileAppender());
    }
View Full Code Here

  SshLog(final Provider<SshSession> session, final Provider<Context> context,
      final SitePaths site, @GerritServerConfig Config config) {
    this.session = session;
    this.context = context;

    final DailyRollingFileAppender dst = new DailyRollingFileAppender();
    dst.setName(LOG_NAME);
    dst.setLayout(new MyLayout());
    dst.setEncoding("UTF-8");
    dst.setFile(new File(resolve(site.logs_dir), LOG_NAME).getPath());
    dst.setImmediateFlush(true);
    dst.setAppend(true);
    dst.setThreshold(Level.INFO);
    dst.setErrorHandler(new DieErrorHandler());
    dst.activateOptions();
    dst.setErrorHandler(new LogLogHandler());

    async = new AsyncAppender();
    async.setBlocking(true);
    async.setBufferSize(config.getInt("core", "asyncLoggingBufferSize", 64));
    async.setLocationInfo(false);
View Full Code Here

      String username = System.getProperty("user.name");
      logFile = String.format("%s%shadoop-%s-fairscheduler.log",
          logDir, File.separator, username);
      logDisabled = false;
      PatternLayout layout = new PatternLayout("%d{ISO8601}\t%m%n");
      appender = new DailyRollingFileAppender(layout, logFile, "'.'yyyy-MM-dd");
      appender.activateOptions();
      LOG.info("Initialized fair scheduler event log, logging to " + logFile);
    } catch (IOException e) {
      LOG.error(
          "Failed to initialize fair scheduler event log. Disabling it.", e);
View Full Code Here

      String username = System.getProperty("user.name");
      logFile = String.format("%s%shadoop-%s-fairscheduler-%s.log",
          logDir, File.separator, username, jobtrackerHostname);
      logDisabled = false;
      PatternLayout layout = new PatternLayout("%d{ISO8601}\t%m%n");
      appender = new DailyRollingFileAppender(layout, logFile, "'.'yyyy-MM-dd");
      appender.activateOptions();
      LOG.info("Initialized fair scheduler event log, logging to " + logFile);
    } catch (IOException e) {
      LOG.error(
          "Failed to initialize fair scheduler event log. Disabling it.", e);
View Full Code Here

            }

            m_configLogger = new Thread(new ConfigLogging());
            m_configLogger.start();

            DailyRollingFileAppender dailyAppender = null;
            Enumeration<?> appenders = Logger.getRootLogger().getAllAppenders();
            while (appenders.hasMoreElements()) {
                Appender appender = (Appender) appenders.nextElement();
                if (appender instanceof DailyRollingFileAppender){
                    dailyAppender = (DailyRollingFileAppender) appender;
                }
            }
            final DailyRollingFileAppender dailyRollingFileAppender = dailyAppender;

            Field field = null;
            if (dailyRollingFileAppender != null) {
                try {
                    field = dailyRollingFileAppender.getClass().getDeclaredField("nextCheck");
                    field.setAccessible(true);
                } catch (NoSuchFieldException e) {
                    hostLog.error("Failed to set daily system info logging: " + e.getMessage());
                }
            }
View Full Code Here

        C.setImmediateFlush(true);
        C.activateOptions();
        logger.addAppender(C);
      }
      // Setup file logging
      DailyRollingFileAppender A = new DailyRollingFileAppender();
      A.setFile(logFilePath);
      A.setDatePattern(fileDatePattern);
      A.setLayout(layout);
      A.activateOptions();
      logger.addAppender(A);
    }
    return logger;
  }
View Full Code Here

        String username = System.getProperty("user.name");
        logFile = String.format("%s%shadoop-%s-fairscheduler.log",
            logDir, File.separator, username);
        logDisabled = false;
        PatternLayout layout = new PatternLayout("%d{ISO8601}\t%m%n");
        appender = new DailyRollingFileAppender(layout, logFile, "'.'yyyy-MM-dd");
        appender.activateOptions();
        LOG.info("Initialized fair scheduler event log, logging to " + logFile);
      } catch (IOException e) {
        LOG.error(
            "Failed to initialize fair scheduler event log. Disabling it.", e);
View Full Code Here

   
    public static void setupLogger(Properties properties) throws IOException {

        Layout layout = new PatternLayout("%d{yyyy-MM-dd HH:mm:ss} %5p: %m%n");

        Appender appender = new DailyRollingFileAppender(
                layout, properties.getProperty("logger.file"), "'.'yyyyMMdd");

        LogManager.resetConfiguration();
        LogManager.getRootLogger().addAppender(new NullAppender());
       
View Full Code Here

TOP

Related Classes of org.apache.log4j.DailyRollingFileAppender

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.