Package org.apache.log4j

Examples of org.apache.log4j.Layout


      PropertyConfigurator.configure(logConfigFileName);
    } else {
      ApplicationFiles appFiles = new ApplicationFiles();
     
      String logMessagePattern = "%-4r [%t] %-5p %c %x - %m%n";
      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());
View Full Code Here


    logViewerVC = createVelocityContainer("logviewer");
    logViewerVC.contextPut("loggingPackage", loggingPackage);
    // Create logger for requested package and add a string writer appender
    log4JLogger = Logger.getLogger(loggingPackage);
    writer = new StringWriter();
    Layout layout = new PatternLayout("%d{HH:mm:ss} %-5p [%t]: %m%n");
    writerAppender = new WriterAppender(layout, writer);
    writerAppender.setThreshold(level);
    log4JLogger.addAppender(writerAppender);
    updateLogViewFromWriter();
    // Add job to read from the string writer every second
View Full Code Here

  /**
   * Test two parameter constructor.
   */
  public void testTwoParamConstructor() {
    Layout layout = new PatternLayout();
    SyslogAppender appender = new SyslogAppender(layout, 24);
    assertEquals("daemon", appender.getFacility());
    assertEquals(false, appender.getFacilityPrinting());
    assertEquals(layout, appender.getLayout());
    assertNull(appender.getSyslogHost());
View Full Code Here

  /**
   * Test two parameter constructor with unexpected facility.
   */
  public void testTwoParamConstructorBadFacility() {
    Layout layout = new PatternLayout();
    SyslogAppender appender = new SyslogAppender(layout, 25);
    assertEquals("user", appender.getFacility());
    assertEquals(false, appender.getFacilityPrinting());
    assertEquals(layout, appender.getLayout());
    assertNull(appender.getSyslogHost());
View Full Code Here

  /**
   * Test three parameter constructor.
   */
  public void testThreeParamConstructor() {
    Layout layout = new PatternLayout();
    SyslogAppender appender =
      new SyslogAppender(layout, "syslog.example.org", 24);
    assertEquals("daemon", appender.getFacility());
    assertEquals(false, appender.getFacilityPrinting());
    assertEquals(layout, appender.getLayout());
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();
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);
View Full Code Here

        String ndcMessage ="<envelope><faultstring><![CDATA[The EffectiveDate]]></faultstring><envelope>";
        NDC.push(ndcMessage);
        LoggingEvent event =
          new LoggingEvent(
            "com.example.bar", logger, level, "Hello, World", null);
        Layout layout = createLayout();
        String result = layout.format(event);
        NDC.clear();
        Element parsedResult = parse(result);
        NodeList ndcs = parsedResult.getElementsByTagName("log4j:NDC");
        assertEquals(1, ndcs.getLength());
        StringBuffer buf = new StringBuffer();
View Full Code Here

        Level level = Level.INFO;
        String exceptionMessage ="<envelope><faultstring><![CDATA[The EffectiveDate]]></faultstring><envelope>";
        LoggingEvent event =
          new LoggingEvent(
            "com.example.bar", logger, level, "Hello, World", new Exception(exceptionMessage));
        Layout layout = createLayout();
        String result = layout.format(event);
        Element parsedResult = parse(result);
        NodeList throwables = parsedResult.getElementsByTagName("log4j:throwable");
        assertEquals(1, throwables.getLength());
        StringBuffer buf = new StringBuffer();
        for(Node child = throwables.item(0).getFirstChild();
View Full Code Here

        message("The repository has been successfully copied.");
    }

    private void prepareServerLog(File log)
            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()));
View Full Code Here

TOP

Related Classes of org.apache.log4j.Layout

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.