diff --git a/housekeeping/src/main/groovy/whelk/HouseKeepingServer.java b/housekeeping/src/main/groovy/whelk/HouseKeepingServer.java index 54048228d0..fa8aefa0b0 100644 --- a/housekeeping/src/main/groovy/whelk/HouseKeepingServer.java +++ b/housekeeping/src/main/groovy/whelk/HouseKeepingServer.java @@ -77,6 +77,6 @@ protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterC } public static void main(String[] args) throws Exception { - new HouseKeepingServer().run(); + new HouseKeepingServer().run(); } } diff --git a/whelktool/src/main/groovy/whelk/datatool/WhelkTool.groovy b/whelktool/src/main/groovy/whelk/datatool/WhelkTool.groovy index d50e8062cd..a20c32fa45 100644 --- a/whelktool/src/main/groovy/whelk/datatool/WhelkTool.groovy +++ b/whelktool/src/main/groovy/whelk/datatool/WhelkTool.groovy @@ -2,6 +2,7 @@ package whelk.datatool import com.google.common.util.concurrent.MoreExecutors import groovy.transform.Immutable +import org.apache.logging.log4j.Logger import org.codehaus.groovy.jsr223.GroovyScriptEngineImpl import whelk.Document import whelk.IdGenerator @@ -71,6 +72,7 @@ class WhelkTool { PrintWriter createdLog PrintWriter deletedLog ConcurrentHashMap reports = new ConcurrentHashMap<>() + Logger logger Counter counter = new Counter() @@ -428,9 +430,9 @@ class WhelkTool { var newGlobals = bindings.keySet() - globals if (newGlobals) { String msg = "FORBIDDEN - new bindings detected: ${newGlobals}" - System.err.println(msg) - System.err.println("Adding new global bindings during record processing is forbidden (since they share state across threads).") - System.err.println("Aborting.") + log(msg) + log("Adding new global bindings during record processing is forbidden (since they share state across threads).") + log("Aborting.") errorDetected = new Exception(msg) return false } @@ -741,8 +743,13 @@ class WhelkTool { } private void log(String msg) { + if (logger) { + logger.info(msg) + } else { + System.err.println(msg) + } + mainLog.println(msg) - System.err.println(msg) } private void repeat(String msg) { diff --git a/whelktool/src/main/java/whelk/datatool/bulkchange/BulkPreviewJob.java b/whelktool/src/main/java/whelk/datatool/bulkchange/BulkPreviewJob.java index 0c0e5efa08..a9bdefe4a4 100644 --- a/whelktool/src/main/java/whelk/datatool/bulkchange/BulkPreviewJob.java +++ b/whelktool/src/main/java/whelk/datatool/bulkchange/BulkPreviewJob.java @@ -30,6 +30,7 @@ public BulkPreviewJob(Whelk whelk, String id) throws IOException { tool.setDryRun(true); tool.setRecordChanges(true); tool.setRecordingLimit(RECORD_MAX_ITEMS); + tool.setLogger(log); } public boolean isFinished() {