Hi, Doug, On Mon, May 17, 2004 at 01:25:05PM -0700, Doug Cutting wrote: > [EMAIL PROTECTED] wrote: > >My patch uses PDFBox to parse pdf files. PDFBox uses log4j. > > Ideally we could configure log4j so that it uses Java's built-in logging > API as a backend. That way folks could still, e.g., redirect all log > messages with a single API. Do you know if that's possible?
I have found a way to have the redirect (from log4j to java's built-in) work. A minor patch is thus attached. It should be applied only after the major patch (sent in my ealier mail) has been applied. They both can be grabbed at http://nutch.neasys.com/patch/ together with a slightly modified note.txt. John -------------------------patch.txt.20040516.1----------------------------- diff -Nur --exclude='*.html' nutch-20040514-cvs/src/java/net/nutch/indexer/IndexSimple.java nutch-20040514-cvs.xing.1/src/java/net/nutch/indexer/IndexSimple.java --- nutch-20040514-cvs/src/java/net/nutch/indexer/IndexSimple.java 2004-05-16 09:19:26.000000000 -0700 +++ nutch-20040514-cvs.xing.1/src/java/net/nutch/indexer/IndexSimple.java 2004-05-17 23:36:58.000000000 -0700 @@ -116,6 +116,7 @@ this.className = className; this.textable = (Textable) createTextable(className); + this.textable.init(); this.totalDocs = 0; this.selectedDocs = 0; diff -Nur --exclude='*.html' nutch-20040514-cvs/src/java/net/nutch/types/application/Pdf.java nutch-20040514-cvs.xing.1/src/java/net/nutch/types/application/Pdf.java --- nutch-20040514-cvs/src/java/net/nutch/types/application/Pdf.java 2004-05-16 09:19:26.000000000 -0700 +++ nutch-20040514-cvs.xing.1/src/java/net/nutch/types/application/Pdf.java 2004-05-17 23:48:23.000000000 -0700 @@ -32,6 +32,23 @@ // text stripper private PDFTextStripper stripper = new PDFTextStripper(); + // initialization + public void init() throws IOException { + + // direct org.apache.log4j.Logger to java's native logger. + org.apache.log4j.Logger rootLogger = + org.apache.log4j.Logger.getRootLogger(); + + rootLogger.setLevel(org.apache.log4j.Level.INFO); + + org.apache.log4j.Appender appender = new org.apache.log4j.WriterAppender( + new org.apache.log4j.SimpleLayout(), + net.nutch.util.LogFormatter.getLogStream( + this.LOG, java.util.logging.Level.INFO)); + + rootLogger.addAppender(appender); + } + public void parse() throws IOException { super.parse(); diff -Nur --exclude='*.html' nutch-20040514-cvs/src/java/net/nutch/types/CheckOneClass.java nutch-20040514-cvs.xing.1/src/java/net/nutch/types/CheckOneClass.java --- nutch-20040514-cvs/src/java/net/nutch/types/CheckOneClass.java 2004-05-16 09:19:26.000000000 -0700 +++ nutch-20040514-cvs.xing.1/src/java/net/nutch/types/CheckOneClass.java 2004-05-17 23:42:04.000000000 -0700 @@ -87,6 +87,7 @@ Textable textable = (Textable) createTextable(className); + textable.init(); textable.setContent(content); textable.parse(); diff -Nur --exclude='*.html' nutch-20040514-cvs/src/java/net/nutch/types/Textable.java nutch-20040514-cvs.xing.1/src/java/net/nutch/types/Textable.java --- nutch-20040514-cvs/src/java/net/nutch/types/Textable.java 2004-05-16 09:19:26.000000000 -0700 +++ nutch-20040514-cvs.xing.1/src/java/net/nutch/types/Textable.java 2004-05-17 23:31:48.000000000 -0700 @@ -1,10 +1,15 @@ package net.nutch.types; +import net.nutch.util.LogFormatter; + import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; //import org.apache.lucene.index.IndexWriter; //import org.apache.lucene.analysis.SimpleAnalyzer; +import java.util.logging.Logger; +//import java.util.logging.Level; + import java.io.OutputStream; import java.io.IOException; @@ -17,6 +22,9 @@ public abstract class Textable { + public static final Logger LOG = + LogFormatter.getLogger("net.nutch.types.Textable"); + // raw content in bytes protected byte[] content = null; @@ -27,8 +35,7 @@ private boolean isUnStored = true; // constructor - public Textable() { - } + public Textable() {} public void setUnStored(boolean isUnStored) { this.isUnStored = isUnStored; @@ -44,6 +51,9 @@ this.luceneDocument = doc; } + // initialization + public void init() throws IOException {} + // parse raw content public void parse() throws IOException { if (this.content == null) ------------------------------------------------------- This SF.Net email is sponsored by: SourceForge.net Broadband Sign-up now for SourceForge Broadband and get the fastest 6.0/768 connection for only $19.95/mo for the first 3 months! http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click _______________________________________________ Nutch-developers mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/nutch-developers
