Package org.apache.log4j

Examples of org.apache.log4j.FileAppender


    root.getLoggerRepository().resetConfiguration();
  }

  public void basic() throws Exception {
    XMLLayout xmlLayout = new XMLLayout();
    root.addAppender(new FileAppender(xmlLayout, TEMP, false));
    common();
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        new LineNumberFilter(),
View Full Code Here


  }

  public void locationInfo() throws Exception {
    XMLLayout xmlLayout = new XMLLayout();
    xmlLayout.setLocationInfo(true);
    root.addAppender(new FileAppender(xmlLayout, TEMP, false));
    common();
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        new LineNumberFilter(),
View Full Code Here

  }

  public void testCDATA() throws Exception {
    XMLLayout xmlLayout = new XMLLayout();
    xmlLayout.setLocationInfo(true);
    root.addAppender(new FileAppender(xmlLayout, TEMP, false));

    String oldThreadName = Thread.currentThread().getName();
    Thread.currentThread().setName("main");
   
    logger.trace("Message with embedded <![CDATA[<hello>hi</hello>]]>.");
View Full Code Here

    assertTrue(Compare.compare(FILTERED, "witness/xmlLayout.3"));
  }

  public void testNull() throws Exception {
    XMLLayout xmlLayout = new XMLLayout();
    root.addAppender(new FileAppender(xmlLayout, TEMP, false));

    String oldThreadName = Thread.currentThread().getName();
    Thread.currentThread().setName("main");

    logger.debug("hi");
View Full Code Here

     * @throws Exception
     */
    public void testMDC() throws Exception {
      XMLLayout xmlLayout = new XMLLayout();
      xmlLayout.setProperties(true);
      root.addAppender(new FileAppender(xmlLayout, TEMP, false));

      Hashtable context = MDC.getContext();
      if (context != null) {
          context.clear();
      }
View Full Code Here

    }

    public void testMDCEscaped() throws Exception {
      XMLLayout xmlLayout = new XMLLayout();
      xmlLayout.setProperties(true);
      root.addAppender(new FileAppender(xmlLayout, TEMP, false));

      Hashtable context = MDC.getContext();
      if (context != null) {
          context.clear();
      }
View Full Code Here

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

        Logger jackrabbitLog = Logger.getRootLogger();
        jackrabbitLog.addAppender(new FileAppender(
                layout, new File(log, "jackrabbit.log").getPath()));

        Logger jettyLog = Logger.getLogger("org.mortbay.log");
        jettyLog.addAppender(new FileAppender(
                layout, new File(log, "jetty.log").getPath()));
        jettyLog.setAdditivity(false);

        if (command.hasOption("debug")) {
            jackrabbitLog.setLevel(Level.DEBUG);
View Full Code Here

        if (! logFile.getParentFile().mkdirs())
        {
          Logger.getRootLogger().error("unable to create parent directory for log file: " + logFile);
        }
      }
      FileAppender fileAppender = null;
      try
      {
        fileAppender = new FileAppender(defaultLayout, fileLogPath);
      }
      catch (IOException io)
      {
        Logger.getRootLogger().error(io);
      }
View Full Code Here

        File file = TestFileUtils.createTempFile(this, ".log", "QpidCompositeRollingAppender");
        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>();
        _appenders.add(fileAppender);
        _appenders.add(dailyRollingFileAppender);
        _appenders.add(rollingFileAppender);
        _appenders.add(externallyRolledFileAppender);
        _appenders.add(qpidCompositeRollingAppender);

        for (Appender appender : _appenders)
        {
            FileAppender fa = (FileAppender) appender;
            fa.setName(fa.getClass().getSimpleName());
            fa.setFile(_appendersFiles.get(fa.getClass().getSimpleName()).get(0).getPath());
        }

        _helper = new LogFileHelper(_appenders);
    }
View Full Code Here

        Logger logger = Logger.getLogger(ColumnPruneVisitor.class);
        logger.removeAllAppenders();
        logger.setLevel(Level.INFO);
        SimpleLayout layout = new SimpleLayout();
        logFile = File.createTempFile("log", "");
        FileAppender appender = new FileAppender(layout, logFile.toString(), false, false, 0);
        logger.addAppender(appender);
       
        Logger pigStorageWithTraceLogger = Logger.getLogger(PigStorageWithTrace.class);
        pigStorageWithTraceLogger.setLevel(Level.INFO);
        pigStorageWithTraceLogger.addAppender(appender);
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.