Author: nmalin
Date: Tue Feb 7 19:56:56 2017 New Revision: 1782071 URL: http://svn.apache.org/viewvc?rev=1782071&view=rev Log: Fixed: Birt logging unlogical high (OFBIZ-9201) Backport from trunk. 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/branches/release16.11/specialpurpose/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java ofbiz/branches/release16.11/specialpurpose/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java Modified: ofbiz/branches/release16.11/specialpurpose/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/specialpurpose/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java?rev=1782071&r1=1782070&r2=1782071&view=diff ============================================================================== --- ofbiz/branches/release16.11/specialpurpose/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java (original) +++ ofbiz/branches/release16.11/specialpurpose/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java Tue Feb 7 19:56:56 2017 @@ -20,8 +20,10 @@ package org.apache.ofbiz.birt; import java.io.OutputStream; import java.sql.SQLException; +import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.logging.Level; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; @@ -29,6 +31,7 @@ import javax.servlet.http.HttpServletRes import javax.servlet.http.HttpSession; 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; @@ -41,6 +44,7 @@ import org.eclipse.birt.report.engine.ap import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.GeneralException; import org.apache.ofbiz.base.util.UtilGenerics; +import org.apache.ofbiz.base.util.UtilProperties; import org.apache.ofbiz.base.util.UtilValidate; import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.security.Security; @@ -60,6 +64,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 @@ -214,4 +230,21 @@ public final class BirtWorker { public static String getBirtOutputFileName () { return BIRT_OUTPUT_FILE_NAME; } + + /** + * initialize configuration 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/branches/release16.11/specialpurpose/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/specialpurpose/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java?rev=1782071&r1=1782070&r2=1782071&view=diff ============================================================================== --- ofbiz/branches/release16.11/specialpurpose/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java (original) +++ ofbiz/branches/release16.11/specialpurpose/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java Tue Feb 7 19:56:56 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 |