Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

*) Making proxyAccessLogging configureable via yacy.logging file - logging can be disabled now - logging directory / filelimit / rotation count can be configured now See: http://www.yacy-forum.de/viewtopic.php?t=965&postdays=0&postorder=asc&start=30#8280

theliaf7b8f75bd5f
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java
index 03faba792..8b7e930e8 100644
--- a/source/de/anomic/http/httpdProxyHandler.java
+++ b/source/de/anomic/http/httpdProxyHandler.java
@@ -59,12 +59,9 @@
package de.anomic.http;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PushbackInputStream;
import java.net.BindException;
@@ -77,13 +74,12 @@ import java.net.UnknownHostException;
import java.util.Date;
import java.util.HashSet;
import java.util.Properties;
-import java.util.TreeMap;
import java.util.logging.FileHandler;
import java.util.logging.Level;
+import java.util.logging.LogManager;
import java.util.logging.Logger;
import java.util.zip.GZIPOutputStream;
-import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterContentTransformer;
import de.anomic.htmlFilter.htmlFilterOutputStream;
import de.anomic.htmlFilter.htmlFilterTransformer;
@@ -124,21 +120,51 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
private File htRootPath = null;
private static boolean doAccessLogging = false;
+
/**
* Do logging configuration for special proxy access log file
*/
static {
try {
- Logger proxyLogger = Logger.getLogger("PROXY.access");
- proxyLogger.setUseParentHandlers(false);
- FileHandler txtLog = new FileHandler("log/proxyAccess%u%g.log",1024*1024, 20, true);
- txtLog.setFormatter(new serverMiniLogFormatter());
- txtLog.setLevel(Level.FINEST);
- proxyLogger.addHandler(txtLog);
+ serverLog.logInfo("PROXY","Configuring proxy access logging ...");
+
+ // getting the logging manager
+ LogManager manager = LogManager.getLogManager();
+ String className = httpdProxyHandler.class.getName();
- doAccessLogging = true;
+ // determining if proxy access logging is enabled
+ String enabled = manager.getProperty("de.anomic.http.httpdProxyHandler.logging.enabled");
+ if ("true".equalsIgnoreCase(enabled)) {
+
+ // reading out some needed configuration properties
+ int limit = 1024*1024, count = 20;
+ String pattern = manager.getProperty(className + ".logging.FileHandler.pattern");
+ if (pattern == null) pattern = "log/proxyAccess%u%g.log";
+
+ String limitStr = manager.getProperty(className + ".logging.FileHandler.limit");
+ if (limitStr != null) try { limit = Integer.valueOf(limitStr).intValue(); } catch (NumberFormatException e) {}
+
+ String countStr = manager.getProperty(className + ".logging.FileHandler.count");
+ if (countStr != null) try { count = Integer.valueOf(countStr).intValue(); } catch (NumberFormatException e) {}
+
+ // creating the proxy access logger
+ Logger proxyLogger = Logger.getLogger("PROXY.access");
+ proxyLogger.setUseParentHandlers(false);
+ FileHandler txtLog = new FileHandler(pattern,limit,count,true);
+ txtLog.setFormatter(new serverMiniLogFormatter());
+ txtLog.setLevel(Level.FINEST);
+ proxyLogger.addHandler(txtLog);
+
+ doAccessLogging = true;
+ serverLog.logInfo("PROXY","Proxy access logging configuration done." +
+ "\n\tFilename: " + pattern +
+ "\n\tLimit: " + limitStr +
+ "\n\tCount: " + countStr);
+ } else {
+ serverLog.logInfo("PROXY","Proxy access logging is deactivated.");
+ }
} catch (Exception e) {
- System.err.println("PROXY: Unable to configure proxy access logging.");
+ serverLog.logError("PROXY","Unable to configure proxy access logging.",e);
}
}
diff --git a/source/de/anomic/plasma/plasmaCrawlWorker.java b/source/de/anomic/plasma/plasmaCrawlWorker.java
index a9d5e867a..0306b896e 100644
--- a/source/de/anomic/plasma/plasmaCrawlWorker.java
+++ b/source/de/anomic/plasma/plasmaCrawlWorker.java
@@ -87,24 +87,24 @@ public final class plasmaCrawlWorker extends Thread {
private boolean stopped = false;
private boolean done = false;
- private static boolean doAccessLogging = false;
+ private static boolean doCrawlerLogging = false;
/**
* Do logging configuration for special proxy access log file
*/
- static {
- try {
- Logger crawlerLogger = Logger.getLogger("CRAWLER.access");
- crawlerLogger.setUseParentHandlers(false);
- FileHandler txtLog = new FileHandler("log/crawlerAccess%u%g.log",1024*1024, 20, true);
- txtLog.setFormatter(new serverMiniLogFormatter());
- txtLog.setLevel(Level.FINEST);
- crawlerLogger.addHandler(txtLog);
-
- doAccessLogging = true;
- } catch (Exception e) {
- System.err.println("PROXY: Unable to configure proxy access logging.");
- }
- }
+// static {
+// try {
+// Logger crawlerLogger = Logger.getLogger("CRAWLER.access");
+// crawlerLogger.setUseParentHandlers(false);
+// FileHandler txtLog = new FileHandler("log/crawlerAccess%u%g.log",1024*1024, 20, true);
+// txtLog.setFormatter(new serverMiniLogFormatter());
+// txtLog.setLevel(Level.FINEST);
+// crawlerLogger.addHandler(txtLog);
+//
+// doAccessLogging = true;
+// } catch (Exception e) {
+// System.err.println("PROXY: Unable to configure proxy access logging.");
+// }
+// }
public plasmaCrawlWorker(
ThreadGroup theTG,
diff --git a/source/de/anomic/server/logging/serverLog.java b/source/de/anomic/server/logging/serverLog.java
index f2eb86916..c98bc8ef3 100644
--- a/source/de/anomic/server/logging/serverLog.java
+++ b/source/de/anomic/server/logging/serverLog.java
@@ -169,6 +169,7 @@ public final class serverLog {
// generating the root logger
Logger logger = Logger.getLogger("");
+
// System.setOut(new PrintStream(new LoggerOutputStream(Logger.getLogger("STDOUT"),Level.FINEST)));
// System.setErr(new PrintStream(new LoggerOutputStream(Logger.getLogger("STDERR"),Level.SEVERE)));
} finally {
diff --git a/yacy.logging b/yacy.logging
index 3cde28b96..cf8e62fda 100644
--- a/yacy.logging
+++ b/yacy.logging
@@ -12,7 +12,7 @@
# INFO regular action information (i.e. any httpd request URL)
# FINEST in-function status debug output
PARSER.level = INFO
-YACY.level = INFO
+YACY.level = FINEST
HTCACHE.level = INFO
PLASMA.level = INFO
SERVER.level = INFO
@@ -39,7 +39,12 @@ de.anomic.server.logging.ConsoleOutErrHandler.level = ALL
de.anomic.server.logging.ConsoleOutErrHandler.levelStdOut = ALL
de.anomic.server.logging.ConsoleOutErrHandler.levelSplit = WARNING
de.anomic.server.logging.ConsoleOutErrHandler.levelStdErr = ALL
-de.anomic.server.logging.ConsoleOutErrHandler.ignoreChr7 = FALSE
de.anomic.server.logging.ConsoleOutErrHandler.formatter=de.anomic.server.logging.serverSimpleLogFormatter
#de.anomic.server.logging.ConsoleOutErrHandler.ignoreCtrlChr=true
+# Properties for the proxy access logger
+de.anomic.http.httpdProxyHandler.logging.enabled = TRUE
+de.anomic.http.httpdProxyHandler.logging.FileHandler.limit = 1048576
+de.anomic.http.httpdProxyHandler.logging.FileHandler.count = 20
+de.anomic.http.httpdProxyHandler.logging.FileHandler.pattern = log/proxyAccess%u%g.log
+