Package org.apache.log4j.spi

Examples of org.apache.log4j.spi.LocationInfo


    assertEquals(2, listAppender.list.size());

    {
      LoggingEvent e = listAppender.list.get(0);
      LocationInfo li = e.getLocationInformation();
      assertEquals(this.getClass().getName(), li.getClassName());
      assertEquals(""+line, li.getLineNumber());
    }
   
    {
      LoggingEvent e = listAppender.list.get(1);
      LocationInfo li = e.getLocationInformation();
      assertEquals(this.getClass().getName(), li.getClassName());
      assertEquals(""+(line+1), li.getLineNumber());
    }

  }
View Full Code Here


    assertEquals(2, listAppender.list.size());
    for (int i=0; i < 2; ++i) {
      LoggingEvent event = listAppender.list.get(i);
      verify(event, data[i].toXML());
      LocationInfo li = event.getLocationInformation();
      assertEquals(this.getClass().getName(), li.getClassName());
      assertEquals(event.getMDC("hostname"), "localhost");
    }
  }
View Full Code Here

    // get the location info in the event.
    // Note that this must have been computed previously
    // within an appender for the following assertion to
    // work properly
    LocationInfo li = le.getLocationInformation();
    System.out.println(li.fullInfo);
    assertEquals("SLF4JBridgeHandlerTest.java", li.getFileName());
    assertEquals("testSmoke", li.getMethodName());
  }
View Full Code Here

     // Capture the logging output without actually logging it
     appender.addFilter(new org.apache.log4j.spi.Filter() {
       @Override
       public int decide(LoggingEvent event) {
         records.add(event);
         LocationInfo l = event.getLocationInformation();
         System.out.printf("[%s:%s] %s%n", l.getFileName(), l.getLineNumber(), event.getMessage());
         assertEquals(TestLog4jLogger_impl.this.getClass().getSimpleName()+".java",
                 l.getFileName());
         return org.apache.log4j.spi.Filter.DENY;
       }
     });
    
      // create Logger
View Full Code Here

     // Capture the logging output without actually logging it
     appender.addFilter(new org.apache.log4j.spi.Filter() {
       @Override
       public int decide(LoggingEvent event) {
         records.add(event);
         LocationInfo l = event.getLocationInformation();
         System.out.printf("[%s:%s] %s%n", l.getFileName(), l.getLineNumber(), event.getMessage());
         assertEquals(TestLog4jLogger_impl.this.getClass().getSimpleName()+".java",
                 l.getFileName());
         return org.apache.log4j.spi.Filter.DENY;
       }
     });

      // create Logger
View Full Code Here

    sbuf.append("<td title=\"" + event.categoryName + " category\">");
    sbuf.append(escapeHTMLTags(event.categoryName));
    sbuf.append("</td>" + Layout.LINE_SEP);

    if(locationInfo) {
      LocationInfo locInfo = event.getLocationInformation();
      sbuf.append("<td>");
      sbuf.append(escapeHTMLTags(locInfo.getFileName()));
      sbuf.append(':');
      sbuf.append(locInfo.getLineNumber());
      sbuf.append("</td>" + Layout.LINE_SEP);
    }

    sbuf.append("<td title=\"Message\">");
    sbuf.append(escapeHTMLTags(event.getRenderedMessage()));
View Full Code Here

      this.type = type;
    }
   
    public
    String convert(LoggingEvent event) {
      LocationInfo locationInfo = event.getLocationInformation();
      switch(type) {
      case FULL_LOCATION_CONVERTER:
  return locationInfo.fullInfo;
      case METHOD_LOCATION_CONVERTER:
  return locationInfo.getMethodName();
      case LINE_LOCATION_CONVERTER:
  return locationInfo.getLineNumber();
      case FILE_LOCATION_CONVERTER:
  return locationInfo.getFileName();
      default: return null;
      }
    }
View Full Code Here

   }
   buf.append("]]></log4j:throwable>\r\n");
       }

       if(locationInfo) {
   LocationInfo locationInfo = event.getLocationInformation()
   buf.append("<log4j:locationInfo class=\"");
   buf.append(locationInfo.getClassName());
   buf.append("\" method=\"");
   buf.append(locationInfo.getMethodName());
   buf.append("\" file=\"");
   buf.append(locationInfo.getFileName());
   buf.append("\" line=\"");
   buf.append(locationInfo.getLineNumber());
   buf.append("\"/>\r\n");
       }

    buf.append("</log4j:event>\r\n\r\n");
View Full Code Here

    // get the location info in the event.
    // Note that this must have been computed previously
    // within an appender for the following assertion to
    // work properly
    LocationInfo li = le.getLocationInformation();
    System.out.println(li.fullInfo);
    assertEquals("SLF4JBridgeHandlerTest.java", li.getFileName());
    assertEquals("testSmoke", li.getMethodName());
  }
View Full Code Here

    // Capture the logging output without actually logging it
    appender.addFilter(new org.apache.log4j.spi.Filter() {
      @Override
      public int decide(LoggingEvent event) {
        records.add(event);
        LocationInfo l = event.getLocationInformation();
        System.out.printf("[%s:%s] %s%n", l.getFileName(), l.getLineNumber(), event.getMessage());
        return org.apache.log4j.spi.Filter.DENY;
      }
    });

    try {
View Full Code Here

TOP

Related Classes of org.apache.log4j.spi.LocationInfo

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.