Package org.apache.log4j

Examples of org.apache.log4j.Logger$PrivateManager


    Logger log4j = getLogger(context);
    log4j.log(convert2Log4JLevel(level), msg);
  }

  public void log(int level, String context, Throwable t, Object msg) {
    Logger log4j = getLogger(context);
    log4j.log(convert2Log4JLevel(level), msg, t);
  }
View Full Code Here


   * @param urlString
   *          Load FavIcon for this URL
   * @return Filename, or null if error
   */
  public String fetchFavIconForUrl(String urlString) {
    Logger logger = Logger.getRootLogger();
    if (logger != null) {
      logger.setLevel(Level.ERROR);
    }
    int pos = urlString.indexOf("//");
    int firstslash = urlString.indexOf("/", pos + 2);
    if (firstslash >= 0) {
      urlString = urlString.substring(0, firstslash);
View Full Code Here

  public void test() {
    ListHandler listHandler = new ListHandler();
    java.util.logging.Logger root = java.util.logging.Logger.getLogger("");
    root.addHandler(listHandler);
    root.setLevel(Level.FINEST);
    Logger log4jLogger = Logger.getLogger("a");
    Category log4jCategory = Logger.getLogger("b");

    int n = 0;

    log4jLogger.log(org.apache.log4j.Level.DEBUG, "hello"+(++n));
    log4jCategory.log(org.apache.log4j.Level.DEBUG, "world"+(++n));
   
    assertEquals(n, listHandler.list.size());

    for (int i = 0; i < n; i++) {
View Full Code Here

    ListHandler listHandler = new ListHandler();
    java.util.logging.Logger root = java.util.logging.Logger.getLogger("");
    root.addHandler(listHandler);
    root.setLevel(Level.FINEST);
    Logger log4jLogger = Logger.getLogger("a");
    Category log4jCategory = Logger.getLogger("b");

    int n = 0;

    log4jLogger.trace("msg" +(n++));
    log4jLogger.debug("msg" +(n++));
    log4jLogger.info("msg" +(n++));
    log4jLogger.warn("msg" +(n++));
    log4jLogger.error("msg" +(n++));
    log4jLogger.fatal("msg" +(n++));
   
    log4jCategory.debug("msg" +(n++));
    log4jCategory.info("msg" +(n++));
    log4jCategory.warn("msg" +(n++));
    log4jCategory.error("msg" +(n++));
View Full Code Here

        }
      Level logLevel = convert2Log4JLevel(level);
        if ( logLevel == Level.OFF) {
            return false;
        }
        Logger log = getLogger(context);
        return log.isEnabledFor(logLevel);
  }
View Full Code Here

        return log.isEnabledFor(logLevel);
  }

  @Override
  public void log(int level, String context, Object msg) {
    Logger log4j = getLogger(context);
    log4j.log(convert2Log4JLevel(level), msg);
  }
View Full Code Here

import junit.framework.TestCase;

public class Trivial extends TestCase {

  public void testSmoke() {
    Logger l = Logger.getLogger("a");
    l.trace("t");
    l.debug("d");
    l.info("i");
    l.warn("w");
    l.error("e");
    l.fatal("f");

    Exception e = new Exception("testing");
    l.trace("t", e);
    l.debug("d", e);
    l.info("i", e);
    l.warn("w", e);
    l.error("e", e);
    l.fatal("f", e);
  }
View Full Code Here

  protected abstract int combine( int numUsedIndices ) throws IOException;
 
 
  public void run() throws ConfigurationException, IOException {
    final Logger logger = Util.getLogger( this.getClass() );
    final ProgressLogger pl = new ProgressLogger( logger, logInterval );
    pl.displayFreeMemory = true;

    final int maxDocSize;

    if ( writeSizes ) {
      logger.info( "Combining sizes..." );
      final OutputBitStream sizesOutputBitStream = new OutputBitStream( outputBasename + DiskBasedIndex.SIZES_EXTENSION, bufferSize );
      maxDocSize = combineSizes( sizesOutputBitStream );
      sizesOutputBitStream.close();
      logger.info( "Sizes combined." );
    }
    else maxDocSize = -1;
   
    // To write the global count of each term
    final OutputBitStream outputGlobCounts = writeGlobCounts ? new OutputBitStream( outputBasename + DiskBasedIndex.GLOBCOUNTS_EXTENSION ) : null;
    // To write the frequency of each term
    final OutputBitStream frequencies = new OutputBitStream( outputBasename + DiskBasedIndex.FREQUENCIES_EXTENSION );
    // To write the new term list
    final PrintWriter termFile = new PrintWriter( new BufferedWriter( new OutputStreamWriter( new FileOutputStream( outputBasename + DiskBasedIndex.TERMS_EXTENSION ), "UTF-8" ), bufferSize ) );
   
    // The current term
    MutableString currTerm;
   
    // Total number of pointers and occurrences
    long numPointers = 0;
   
    pl.expectedUpdates = writeGlobCounts ? numberOfOccurrences : -1;
    pl.itemsName = writeGlobCounts ? "occurrences" : "terms";
    pl.logInterval = logInterval;
    pl.start( "Combining lists..." );

    int totalFrequency, numTerms = 0, numUsedIndices, k;
    long totalGlobCount = 0;
    predictedSize = -1;
    predictedLengthNumBits = -1;
   
    // Discard first zero from offsets
    if ( p != 0 ) for( InputBitStream ibs: offsets ) ibs.readGamma();
   
    // TODO: use the front of the queue?
    while( ! termQueue.isEmpty() ) {
      numUsedIndices = 0;
      // We read a new word from the queue, copy it and write it to the term file
      currTerm = term[ k = usedIndex[ numUsedIndices++ ] = termQueue.first() ].copy();
     
      if ( DEBUG ) System.err.println( "Merging term " + currTerm );
     
      currTerm.println( termFile );
      if ( termReader[ k ].readLine( term[ k ] ) == null ) termQueue.dequeue();
      else termQueue.changed();
     
      // Then, we extract all equal words from the queue, accumulating the set of indices in inIndex and currIndex
      while( ! termQueue.isEmpty() && term[ termQueue.first() ].equals( currTerm ) ) {
        k = usedIndex[ numUsedIndices++ ] = termQueue.first();
        if ( termReader[ k ].readLine( term[ k ] ) == null ) termQueue.dequeue();
        else termQueue.changed();
      }
     
      if ( numUsedIndices > 1 ) Arrays.sort( usedIndex, 0, numUsedIndices );

      // Load index iterators
      for( int i = numUsedIndices; i-- != 0; ) indexIterator[ usedIndex[ i ] ] = indexReader[ usedIndex[ i ] ].nextIterator();

      numTerms++;

      if ( writeGlobCounts ) {
        // Compute and write the total global count. This works for all kind of indices.
        totalGlobCount = 0;
        for( int i = 0; i < numUsedIndices; i++ ) totalGlobCount += globCounts[ usedIndex[ i ] ].readLongGamma();
        outputGlobCounts.writeLongGamma( totalGlobCount );
      }
           
      if ( p != 0 ) {
        predictedSize = 0;
        predictedLengthNumBits = 0;

        for( int i = numUsedIndices; i-- != 0; ) {

          if ( index[ usedIndex[ i ] ] instanceof BitStreamHPIndex ) {
            predictedSize += offsets[ usedIndex[ i ] ].readLongGamma();
            if ( hasPositions ) predictedLengthNumBits += posNumBits[ usedIndex[ i ] ].readLongGamma();
          }
          else {
            // Interleaved index: we must subtract the number of bits used for positions from the length of the overall inverted list
            final long t = hasPositions ? posNumBits[ usedIndex[ i ] ].readLongGamma() : 0;
            predictedSize += offsets[ usedIndex[ i ] ].readLongGamma() - t;
            predictedLengthNumBits += t;
          }
        }
      }
           
      totalFrequency = combine( numUsedIndices );
      frequencies.writeGamma( totalFrequency );
      numPointers += totalFrequency;

      /* A trick to get a correct prediction. */
      if ( writeGlobCounts ) pl.count += totalGlobCount - 1;
      pl.update();
    }
    pl.done();
   
    if ( writeGlobCounts ) outputGlobCounts.close();
    termFile.close();
    frequencies.close();

    if ( ! metadataOnly ) {
      for( int i = numIndices; i-- != 0; ) {
        indexReader[ i ].close();
        if ( writeGlobCounts ) globCounts[ i ].close();
        if ( p != 0 ) {
          offsets[ i ].close();
          if ( posNumBits[ i ] != null ) posNumBits[ i ].close();
        }
        termReader[ i ].close();
      }
      final long indexSize = indexWriter.writtenBits();
      indexWriter.close();
      final Properties properties = indexWriter.properties();
      additionalProperties.setProperty( Index.PropertyKeys.SIZE, indexSize );
      additionalProperties.setProperty( Index.PropertyKeys.MAXDOCSIZE, maxDocSize );
      additionalProperties.setProperty( Index.PropertyKeys.OCCURRENCES, numberOfOccurrences );
      properties.addAll( additionalProperties );
      logger.debug( "Post-merge properties: " + new ConfigurationMap( properties ) );
      properties.save( outputBasename + DiskBasedIndex.PROPERTIES_EXTENSION );
    }
       
    final PrintStream stats = new PrintStream( new FileOutputStream ( outputBasename + DiskBasedIndex.STATS_EXTENSION ) );
    if ( ! metadataOnly ) indexWriter.printStats( stats );
View Full Code Here

     * @param namespaceName the name of the namespace for which we'll retrieve the logger instance.
     * @return the namespace or root logger instance.
     */
    public static Logger getNamespaceLogger(final String namespaceName)
    {
        Logger logger;
        if (namespaceName != null && !Namespaces.DEFAULT.equals(namespaceName))
        {
            logger = Logger.getLogger(getNamespaceLoggerName(namespaceName));
        }
        else
View Full Code Here

    }

    private Log4JLogger createLogger( final Appender target,
                                      final Level priority )
    {
        final Logger log4jLogger = Logger.getLogger( "test" );
        log4jLogger.removeAllAppenders();
        log4jLogger.addAppender( target );
        log4jLogger.setLevel( priority );
        return new Log4JLogger( log4jLogger );
    }
View Full Code Here

TOP

Related Classes of org.apache.log4j.Logger$PrivateManager

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.