Package org.apache.log4j

Examples of org.apache.log4j.FileAppender


  public static FileAppender getFileAppender(String name, LoggerRepository repository) {
      Set allAppenders = getAllAppenders(repository);
    for (Object allAppender : allAppenders) {
      Appender appender = (Appender) allAppender;
      if (appender instanceof FileAppender) {
        FileAppender fileAppender = (FileAppender) appender;
        if (fileAppender.getName() != null
            && fileAppender.getName().equals(name)) {
          return fileAppender;
        }
      }
    }
    return null;
View Full Code Here


                            ((PatternLayout) layout).getConversionPattern());
                }
            }

            if (appender instanceof FileAppender) {
                FileAppender fileAppender = (FileAppender) appender;
                String fileName = fileAppender.getFile();
                File logFile = new File(fileName);
                if (!logFile.isAbsolute()) {
                    if (fileName.startsWith(".")) {
                        fileName = fileName.substring(1);
                    }
                    fileName = (System.getProperty(ServerConstants.CARBON_HOME) + "/" +
                            fileName).replace('\\', '/');
                    fileAppender.setFile(fileName);
                    fileAppender.activateOptions();
                }
                appenderResource.addProperty(LoggingConstants.AppenderProperties.LOG_FILE_NAME, fileName);
                appenderResource.addProperty(LoggingConstants.AppenderProperties.IS_FILE_APPENDER,
                        Boolean.toString(true));
            } else {
View Full Code Here

            ((PatternLayout) appender.getLayout())
                .setConversionPattern(appenderResource
                    .getProperty(LoggingConstants.AppenderProperties.PATTERN));
          }
          if (appender instanceof FileAppender) {
            FileAppender fileAppender = ((FileAppender) appender);
            fileAppender.setFile(appenderResource
                .getProperty(LoggingConstants.AppenderProperties.LOG_FILE_NAME));
            fileAppender.activateOptions();
          }

          if (appender instanceof MemoryAppender) {
            MemoryAppender memoryAppender = (MemoryAppender) appender;
            memoryAppender.setCircularBuffer(new CircularBuffer(200));
View Full Code Here

       
        String logMessagesFile = "TestGrunt-testExplainScript2-stderr.txt";
        // add a file based appender to the root logger so we can parse the
        // messages logged by grunt and verify that grunt commands are ignored
        // in explain -script mode
        Appender fileAppender = new FileAppender(new PatternLayout(), logMessagesFile);
       
        try {
            org.apache.log4j.LogManager.getRootLogger().addAppender(fileAppender);
            Grunt grunt = new Grunt(new BufferedReader(reader), context);
            grunt.exec();
View Full Code Here

   
    if (debugLog != null) {
      Logger logger = Logger.getLogger(Constants.CORE_PACKAGE_NAME);
      logger.setLevel(Level.TRACE);
      logger.setAdditivity(false);
      logger.addAppender(new FileAppender(new PatternLayout("%d{dd HH:mm:ss,SSS} [%-8c{2}] %-5p: %m%n"), debugLog, true));
    }
   
    initVisibilities();

    String instanceName = args[0];
View Full Code Here

   
    if (debugLog != null) {
      Logger logger = Logger.getLogger(Constants.CORE_PACKAGE_NAME);
      logger.setLevel(Level.TRACE);
      logger.setAdditivity(false);
      logger.addAppender(new FileAppender(new PatternLayout("%d{dd HH:mm:ss,SSS} [%-8c{2}] %-5p: %m%n"), debugLog, true));
    }
   
    String instanceName = args[0];
    String zooKeepers = args[1];
   
View Full Code Here

   
    if (debugLog != null) {
      Logger logger = Logger.getLogger(Constants.CORE_PACKAGE_NAME);
      logger.setLevel(Level.TRACE);
      logger.setAdditivity(false);
      logger.addAppender(new FileAppender(new PatternLayout("%d{dd HH:mm:ss,SSS} [%-8c{2}] %-5p: %m%n"), debugLog, true));
    }
   
    Random r = new Random();

    String instanceName = args[0];
View Full Code Here

   
    if (debugLog != null) {
      Logger logger = Logger.getLogger(Constants.CORE_PACKAGE_NAME);
      logger.setLevel(Level.TRACE);
      logger.setAdditivity(false);
      logger.addAppender(new FileAppender(new PatternLayout("%d{dd HH:mm:ss,SSS} [%-8c{2}] %-5p: %m%n"), debugLog, true));
    }
   
    String instanceName = args[0];
    String zooKeepers = args[1];
   
View Full Code Here

    Logger logger = Logger.getRootLogger();
    try {
      PatternLayout layout = new PatternLayout("%d{HH:mm:ss} %-5p [%t] %m%n");
      ConsoleAppender consoleAppender = new ConsoleAppender(layout);
      logger.addAppender(consoleAppender);
      FileAppender fileAppender = new FileAppender(layout, file.getAbsolutePath(), false);
      logger.addAppender(fileAppender);
      logger.setLevel(Level.INFO);
      logger.info("Logginglevel: " + logger.getLevel());
      logger.info("Date: " + new Date());
    } catch (Exception ex) {
View Full Code Here

    Logger logger = Logger.getRootLogger();
    try {
      PatternLayout layout = new PatternLayout("%d{HH:mm:ss} %-5p [%t] %m%n");
      ConsoleAppender consoleAppender = new ConsoleAppender(layout);
      logger.addAppender(consoleAppender);
      FileAppender fileAppender = new FileAppender(layout, file.getAbsolutePath(), false);
      logger.addAppender(fileAppender);
      logger.setLevel(Level.INFO);
      logger.info("Logginglevel: " + logger.getLevel());
    } catch (Exception ex) {
      YEx.error("Can not generate log", ex);
View Full Code Here

TOP

Related Classes of org.apache.log4j.FileAppender

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.