Author: nmalin
Date: Tue Feb 7 19:56:04 2017 New Revision: 1782070 URL: http://svn.apache.org/viewvc?rev=1782070&view=rev Log: Fixed: Birt logging unlogical high (OFBIZ-9201) Currently the class BirtContainer call the birt engine with hard coded log level ALL that generated huge log file. We can't implement easily log4j on the birt engine so with this commit I create a quick fix to have matching between the java.util.Logger and org.apache.log4j.Logger level. You can select the log level from debug.properties to populate the ReportEngine log file. Modified: ofbiz/trunk/plugins/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java ofbiz/trunk/plugins/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java Modified: ofbiz/trunk/plugins/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java?rev=1782070&r1=1782069&r2=1782070&view=diff ============================================================================== --- ofbiz/trunk/plugins/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java (original) +++ ofbiz/trunk/plugins/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java Tue Feb 7 19:56:04 2017 @@ -23,9 +23,11 @@ import java.io.IOException; import java.io.OutputStream; import java.io.StringWriter; import java.sql.SQLException; +import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.logging.Level; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; @@ -49,6 +51,7 @@ import org.apache.ofbiz.service.LocalDis import org.apache.ofbiz.service.ServiceUtil; import org.apache.ofbiz.webapp.WebAppUtil; import org.eclipse.birt.report.engine.api.EXCELRenderOption; +import org.eclipse.birt.report.engine.api.EngineConfig; import org.eclipse.birt.report.engine.api.EngineException; import org.eclipse.birt.report.engine.api.HTMLRenderOption; import org.eclipse.birt.report.engine.api.HTMLServerImageHandler; @@ -74,6 +77,18 @@ public final class BirtWorker { private BirtWorker() {} + public static final Map<Integer, Level> levelIntMap = new HashMap<>(); + static { + levelIntMap.put(Debug.ERROR, Level.SEVERE); + levelIntMap.put(Debug.TIMING, Level.FINE); + levelIntMap.put(Debug.INFO, Level.INFO); + levelIntMap.put(Debug.IMPORTANT, Level.INFO); + levelIntMap.put(Debug.WARNING, Level.WARNING); + levelIntMap.put(Debug.ERROR, Level.SEVERE); + levelIntMap.put(Debug.FATAL, Level.ALL); + levelIntMap.put(Debug.ALWAYS, Level.ALL); + } + /** * export report * @param design @@ -277,4 +292,20 @@ public final class BirtWorker { return contentId; } + /** + * initialize configuration log with the low level present on debug.properties + * @param config + */ + public static void setLogConfig(EngineConfig config) { + String ofbizHome = System.getProperty("ofbiz.home"); + int lowerLevel = 0; + //resolve the lower level open on debug.properties, maybe it's better to implement correctly log4j here + for (int i = 1; i < 7; i++) { + if (Debug.isOn(i)) { + lowerLevel = i; + break; + } + } + config.setLogConfig(UtilProperties.getPropertyValue("debug", "log4j.appender.css.dir", ofbizHome + "/runtime/logs/"), levelIntMap.get(lowerLevel)); + } } Modified: ofbiz/trunk/plugins/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java?rev=1782070&r1=1782069&r2=1782070&view=diff ============================================================================== --- ofbiz/trunk/plugins/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java (original) +++ ofbiz/trunk/plugins/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java Tue Feb 7 19:56:04 2017 @@ -20,7 +20,6 @@ package org.apache.ofbiz.birt.container; import java.io.File; import java.util.List; -import java.util.logging.Level; import org.eclipse.birt.core.exception.BirtException; import org.eclipse.birt.core.framework.Platform; @@ -34,6 +33,7 @@ import org.apache.ofbiz.base.container.C import org.apache.ofbiz.base.start.StartupCommand; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.birt.BirtFactory; +import org.apache.ofbiz.birt.BirtWorker; public class BirtContainer implements Container { @@ -70,11 +70,13 @@ public class BirtContainer implements Co EngineConfig config = new EngineConfig(); String ofbizHome = System.getProperty("ofbiz.home"); config.setTempDir(ofbizHome + File.separatorChar + "runtime" + File.separatorChar + "tempfiles"); - config.setLogConfig(ofbizHome + File.separatorChar + "runtime" + File.separatorChar + "logs" + File.separatorChar + "birt", Level.ALL); // set system properties System.setProperty(IBirtConstants.SYS_PROP_WORKING_PATH, config.getTempDir()); + //Set log config + BirtWorker.setLogConfig(config); + // startup platform try { Debug.logInfo("Startup BIRT platform", module); |
Free forum by Nabble | Edit this page |