Package org.apache.log4j

Examples of org.apache.log4j.FileAppender


            // send log output to a file
            String filename = commandLine.getOptionValue('f');
           
            try
            {
              Appender newAppender = new FileAppender(new PatternLayout("%d{ISO8601} %c{1}-%p: %m%n"), filename, true);
              newAppender.setName("ConsoleAppender");
              Logger.getRootLogger().removeAppender(con);
              Logger.getRootLogger().addAppender(newAppender);
              ci.out.println("> Logging to filename: " + filename);
            } catch (IOException e)
            {
View Full Code Here


    super(arg0);
  }

  protected void setUp() throws Exception {
    super.setUp();
    fileAppender = new FileAppender(new PatternLayout("%r [%t] %p %c %x - %m%n"), "target/test-output/toto.log");

    existingHandlers = julRootLogger.getHandlers();
    for (int i = 0; i < existingHandlers.length; i++) {
      julRootLogger.removeHandler(existingHandlers[i]);
    }
View Full Code Here

     */
    private void initLogger(String pluginName) throws IOException
    {
        logger = AndroMDALogger.getNamespaceLogger(pluginName);
        logger.setAdditivity(false);
        FileAppender appender = new FileAppender(new PatternLayout("%-5p %d - %m%n"), AndroMDALogger
                .getNamespaceLogFileName(pluginName), true);
        logger.addAppender(appender);
    }
View Full Code Here

        throws IOException
    {
        logger = AndroMDALogger.getNamespaceLogger(pluginName);
        logger.setAdditivity(false);

        final FileAppender appender =
            new FileAppender(
                new PatternLayout("%-5p %d - %m%n"),
                AndroMDALogger.getNamespaceLogFileName(pluginName),
                true);
        logger.addAppender(appender);
    }
View Full Code Here

      Layout layout = new PatternLayout(logMessagePattern);
     
      File logsDir = new File(appFiles.getUserSettingsDirectory(), "logs");
      File updateLogFile = new File(logsDir, "updater.log");
     
      FileAppender appender = new FileAppender(layout, updateLogFile.getAbsolutePath());
     
      LoggerController.registerLoggerFactory(new SquirrelLoggerFactory(appender, false));
    }
  } 
View Full Code Here

                LOG.debug("Console LOG level set to " + consoleThreshold);
            }

            if (fileName != null) {
                PatternLayout layout = new PatternLayout("%d{ABSOLUTE} %-5p %x %m%n");
                FileAppender fileAppender = new FileAppender(layout, fileName, false);
                fileAppender.setName(FILE_APPENDER_NAME);
                Level fileThreshold = Level.toLevel(fileLevel, Level.DEBUG);
                fileAppender.setThreshold(fileThreshold);
                Logger.getRootLogger().addAppender(fileAppender);
                LOG.debug("Added fileAppender (" + fileName + ") at level " + fileThreshold);
            }
        } catch (Exception e) {
            System.err.println("Error configuring logging framework: " + e.getMessage());
View Full Code Here

              }
              return value;
          }
      };
      configurator.doConfigure("input/xml/DOMTestCase1.xml", LogManager.getLoggerRepository());
      FileAppender a1 = (FileAppender) Logger.getRootLogger().getAppender("A1");
      String file = a1.getFile();
      assertEquals("output/subst-test.A1", file);
  }
View Full Code Here

    String mdcMsgPattern4 = "%m : %X{key3}%n";
    String mdcMsgPattern5 = "%m : %X{key1},%X{key2},%X{key3}%n";
   
    // set up appender
    PatternLayout layout = new PatternLayout(msgPattern);
    Appender appender = new FileAppender(layout, OUTPUT_FILE+"_mdc", false);
           
    // set appender on root and set level to debug
    root.addAppender(appender);
    root.setLevel(Level.DEBUG);
   
View Full Code Here

  public void accept() throws Exception {
   
    // set up appender
    Layout layout = new SimpleLayout();
    Appender appender = new FileAppender(layout, ACCEPT_FILE, false);
   
    // create LevelMatchFilter
    LevelMatchFilter matchFilter = new LevelMatchFilter();
     // attach match filter to appender
    appender.addFilter(matchFilter);
  
    // attach DenyAllFilter to end of filter chain to deny neutral
    // (non matching) messages
    appender.addFilter(new DenyAllFilter());
       
    // set appender on root and set level to debug
    root.addAppender(appender);
    root.setLevel(Level.TRACE);
   
View Full Code Here

  public void deny() throws Exception {
   
    // set up appender
    Layout layout = new SimpleLayout();
    Appender appender = new FileAppender(layout, DENY_FILE, false);
   
    // create LevelMatchFilter, set to deny matches
    LevelMatchFilter matchFilter = new LevelMatchFilter();
    matchFilter.setAcceptOnMatch(false);
     // attach match filter to appender
    appender.addFilter(matchFilter);
          
    // set appender on root and set level to debug
    root.addAppender(appender);
    root.setLevel(Level.TRACE);
   
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.