From 132a63900e2605f5849c3eeb6b65477b56e799b0 Mon Sep 17 00:00:00 2001 From: iroqueta Date: Wed, 11 May 2022 19:03:30 -0300 Subject: [PATCH 1/3] Print debug messages in standar classes when GeneXus log is enabled instead of when JDBC log is enabled. Issue: 96165 --- .../java/com/genexus/GXJarClassLoader.java | 18 +++--- .../main/java/com/genexus/ModelContext.java | 14 ++--- .../com/genexus/diagnostics/core/ILogger.java | 2 + .../genexus/internet/GXInternetConstants.java | 2 - .../com/genexus/internet/RFC822EndReader.java | 23 +++---- .../com/genexus/util/DelimitedFilesSafe.java | 61 +++++++------------ .../com/genexus/internet/POP3Session.java | 36 +++-------- .../com/genexus/internet/SMTPSession.java | 35 ++--------- .../main/java/com/genexus/Application.java | 7 +-- .../main/java/com/genexus/CacheFactory.java | 5 +- .../java/com/genexus/util/GXServices.java | 8 ++- .../java/com/genexus/util/LDAPClient.java | 34 +++++------ .../genexus/webpanels/GXWebObjectStub.java | 6 +- .../core/provider/Log4J2Logger.java | 4 ++ 14 files changed, 92 insertions(+), 163 deletions(-) diff --git a/common/src/main/java/com/genexus/GXJarClassLoader.java b/common/src/main/java/com/genexus/GXJarClassLoader.java index 3035a2858..591ccf79e 100644 --- a/common/src/main/java/com/genexus/GXJarClassLoader.java +++ b/common/src/main/java/com/genexus/GXJarClassLoader.java @@ -1,12 +1,14 @@ package com.genexus; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.diagnostics.core.LogManager; + import java.io.*; import java.util.*; import java.util.zip.*; public class GXJarClassLoader extends ClassLoader { - private static final boolean DEBUG = DebugFlag.DEBUG; private String source; private ZipFile zipFile = null; private boolean sourceIsJAR; @@ -15,6 +17,8 @@ public class GXJarClassLoader extends ClassLoader private long jarTimeStamp = 0; private boolean autoReload; private int loadDepth; // Esta variable mantiene un depth de intentos de lectura del Zip + + private static final ILogger logger = LogManager.getLogger(GXJarClassLoader.class); /** El Nombre esta medio mal, porque el GXJarClassLoader obtiene las clases de un JAR o * de una directorio base @@ -30,8 +34,7 @@ public GXJarClassLoader(String location, boolean autoReload) sourceIsJAR = new File(source).isFile(); loadDepth = 0; if(!autoReload)openJar(); - if(DEBUG) - System.out.println("## GXJarClassLoader: Initialized (autoReloading: " + autoReload + ")"); + logger.debug("## GXJarClassLoader: Initialized (autoReloading: " + autoReload + ")"); } /** Obtiene el ClassLoader asociado. En efecto lo que hace es retornarse a s� mismo en el @@ -45,8 +48,7 @@ public GXJarClassLoader getClassLoaderInstance() return this; else { - if (DEBUG) - System.out.println("## GXJarClassLoader: Changed classes detected ..." ); + logger.debug("## GXJarClassLoader: Changed classes detected ..." ); return new GXJarClassLoader(source, autoReload); } } @@ -134,8 +136,7 @@ public synchronized Class loadClass(String className, boolean resolveIt) throws try { result = this.getClass().getClassLoader().loadClass(className); - if(DEBUG) - System.out.println("## GXJarClassLoader: Loading ParentClass: " + className); + logger.debug("## GXJarClassLoader: Loading ParentClass: " + className); return result; }catch(Throwable e) { ; } throw new ClassNotFoundException(className); @@ -168,8 +169,7 @@ private byte[] loadBytes(String className) byte[] result = null; className = className.replace('.', '/') + ".class"; - if(DEBUG) - System.out.println("## GXJarClassLoader: Loading class: " + className + " [" + source + "]"); + logger.debug("## GXJarClassLoader: Loading class: " + className + " [" + source + "]"); try { if(sourceIsJAR) diff --git a/common/src/main/java/com/genexus/ModelContext.java b/common/src/main/java/com/genexus/ModelContext.java index 4df97fdcc..fe4a93846 100644 --- a/common/src/main/java/com/genexus/ModelContext.java +++ b/common/src/main/java/com/genexus/ModelContext.java @@ -9,6 +9,8 @@ import com.genexus.common.interfaces.IClientPreferences; import com.genexus.common.interfaces.IPreferences; import com.genexus.common.interfaces.SpecificImplementation; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.diagnostics.core.LogManager; import com.genexus.util.GUIContextNull; import com.genexus.util.GXThreadLocal; import com.genexus.util.IGUIContext; @@ -34,17 +36,15 @@ public final class ModelContext extends AbstractModelContext public boolean inErrorHandler = false; public static IThreadLocal threadModelContext = GXThreadLocal.newThreadLocal(); + private static final ILogger logger = LogManager.getLogger(ModelContext.class); public static ModelContext getModelContext() { ModelContext context = (ModelContext)threadModelContext.get(); - if(DebugFlag.DEBUG) - { - if(context == null) - { - System.err.println(new Date() + " - Cannot find ModelContext for thread " + Thread.currentThread() ); - } - } + if(context == null) + { + logger.error(new Date() + " - Cannot find ModelContext for thread " + Thread.currentThread() ); + } return context; } diff --git a/common/src/main/java/com/genexus/diagnostics/core/ILogger.java b/common/src/main/java/com/genexus/diagnostics/core/ILogger.java index dc8f1ce48..79424c5be 100644 --- a/common/src/main/java/com/genexus/diagnostics/core/ILogger.java +++ b/common/src/main/java/com/genexus/diagnostics/core/ILogger.java @@ -56,6 +56,8 @@ public interface ILogger { boolean isDebugEnabled(); + boolean isErrorEnabled(); + // Lambda Functions not supported JAVA 7. Only Java 8. /* * public static void debug(Logger log, String startMsg, Func buildMsg) diff --git a/common/src/main/java/com/genexus/internet/GXInternetConstants.java b/common/src/main/java/com/genexus/internet/GXInternetConstants.java index 57059d0a9..02799e98f 100644 --- a/common/src/main/java/com/genexus/internet/GXInternetConstants.java +++ b/common/src/main/java/com/genexus/internet/GXInternetConstants.java @@ -3,8 +3,6 @@ public interface GXInternetConstants { - static boolean DEBUG = com.genexus.DebugFlag.DEBUG; - static String CRLFString = System.getProperty("line.separator"); static String BASE64 = "base64"; diff --git a/common/src/main/java/com/genexus/internet/RFC822EndReader.java b/common/src/main/java/com/genexus/internet/RFC822EndReader.java index 8de90e683..c406538e3 100644 --- a/common/src/main/java/com/genexus/internet/RFC822EndReader.java +++ b/common/src/main/java/com/genexus/internet/RFC822EndReader.java @@ -1,37 +1,30 @@ package com.genexus.internet; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.diagnostics.core.LogManager; + import java.io.*; -class RFC822EndReader extends BufferedReader implements GXInternetConstants +public class RFC822EndReader extends BufferedReader implements GXInternetConstants { private String lastLine; private boolean isEndOfMessage = false; - private PrintStream logOutput; + private static final ILogger logger = LogManager.getLogger(RFC822EndReader.class); - public RFC822EndReader(Reader reader, PrintStream logOutput) + public RFC822EndReader(Reader reader) { super(reader); - this.logOutput = logOutput; } private int log(int line) { - if (DEBUG) - { - if (logOutput != null) - logOutput.println("byte: " + line); - } - + logger.debug("byte: " + line); return line; } private String log(String line) { - if (DEBUG) - { - if (logOutput != null) - logOutput.println("Line: " + line); - } + logger.debug("Line: " + line); return line; } diff --git a/common/src/main/java/com/genexus/util/DelimitedFilesSafe.java b/common/src/main/java/com/genexus/util/DelimitedFilesSafe.java index d72bcaa88..e034162f7 100644 --- a/common/src/main/java/com/genexus/util/DelimitedFilesSafe.java +++ b/common/src/main/java/com/genexus/util/DelimitedFilesSafe.java @@ -7,6 +7,8 @@ import java.io.*; import com.genexus.*; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.diagnostics.core.LogManager; import com.genexus.platform.INativeFunctions; import com.genexus.common.interfaces.SpecificImplementation; @@ -15,6 +17,7 @@ public class DelimitedFilesSafe implements IDelimitedFilesSafe { // variables + private static final ILogger logger = LogManager.getLogger(DelimitedFilesSafe.class); private static final byte GX_ASCDEL_SUCCESS = 0; private static final byte GX_ASCDEL_INVALIDSEQUENCE = -1; @@ -36,7 +39,6 @@ public class DelimitedFilesSafe implements IDelimitedFilesSafe private String sdel; protected boolean dfropen_in_use = false; protected boolean dfwopen_in_use = false; - protected boolean trace_on = DebugFlag.DEBUG; protected BufferedReader bufread; protected BufferedWriter bufwrite; private StringTokenizer actline; @@ -59,8 +61,7 @@ public String getEncoding() public byte dftrace(int trace) { - byte lastTrace = (byte)(trace_on ? 1 : 0); - this.trace_on = (trace != 0); + byte lastTrace = 1; return lastTrace; } @@ -143,16 +144,14 @@ public Object run() throws Exception { retval = GX_ASCDEL_OPENERROR; dfropen_in_use = false; - if (trace_on) - System.err.println("Error ADF0001: " + e); + logger.error("Error ADF0001: " + e); } } else { retval = GX_ASCDEL_INVALIDSEQUENCE; - if (trace_on) - System.err.println("Error ADF0005: open function in use"); + logger.error("Error ADF0005: open function in use"); } return retval; @@ -181,8 +180,7 @@ public byte dfrnext() catch (IOException e) { retval = GX_ASCDEL_READERROR; - if (trace_on) - System.err.println("Error ADF0002: " + e); + logger.error("Error ADF0002: " + e); } }else{ @@ -214,15 +212,13 @@ public byte dfrgnum(double[] num) catch (Exception e) { retval = GX_ASCDEL_INVALIDFORMAT; - if (trace_on) - System.err.println("Error ADF0008: " + e); + logger.error("Error ADF0008: " + e); } } else { retval = GX_ASCDEL_INVALIDSEQUENCE; - if (trace_on) - System.err.println("Error ADF0004 o ADF0006"); + logger.error("Error ADF0004 o ADF0006"); } num[0] = retnum.doubleValue(); @@ -258,15 +254,13 @@ public byte dfrgnum(BigDecimal[] num) catch (Exception e) { retval = GX_ASCDEL_INVALIDFORMAT; - if (trace_on) - System.err.println("Error ADF0008: " + e); + logger.error("Error ADF0008: " + e); } } else { retval = GX_ASCDEL_INVALIDSEQUENCE; - if (trace_on) - System.err.println("Error ADF0004 o ADF0006"); + logger.error("Error ADF0004 o ADF0006"); } num[0] = retnum; @@ -360,15 +354,13 @@ public byte dfrgtxt(String[] str, int len) catch (Exception e) { retval = GX_ASCDEL_INVALIDFORMAT; - if (trace_on) - System.err.println("Error ADF0009: " + e); + logger.error("Error ADF0009: " + e); } } else { retval = GX_ASCDEL_INVALIDSEQUENCE; - if (trace_on) - System.err.println("Error ADF0004 o ADF0006"); + logger.error("Error ADF0004 o ADF0006"); } if (isCsv && ((sdel.equals("") || sdel.equals("\"")) && (retstr.contains("\"\"") || (!fdel.equals("") && retstr.contains(fdel))))) @@ -534,8 +526,7 @@ public byte dfrgdate(java.util.Date[] date, String fmt, String sep) else if (month < 1 || month > 12 || day < 1 || day > 31) { retval = GX_ASCDEL_INVALIDDATE; - if (trace_on) - System.err.println("Error ADF0010"); + logger.error("Error ADF0010"); } else { @@ -553,8 +544,7 @@ else if (month < 1 || month > 12 || day < 1 || day > 31) else { retval = GX_ASCDEL_INVALIDSEQUENCE; - if (trace_on) - System.err.println("Error ADF0004 o ADF0006"); + logger.error("Error ADF0004 o ADF0006"); } date[0] = retdate; @@ -666,16 +656,14 @@ public Object run() throws Exception { retval = GX_ASCDEL_OPENERROR; dfwopen_in_use = false; - if (trace_on) - System.err.println("Error ADF0001: " + e); + logger.error("Error ADF0001: " + e); } } else { retval = GX_ASCDEL_INVALIDSEQUENCE; - if (trace_on) - System.err.println("Error ADF0005: open function in use"); + logger.error("Error ADF0005: open function in use"); } return retval; @@ -737,8 +725,7 @@ public byte dfwnext() catch (IOException e) { retval = GX_ASCDEL_WRITEERROR; - if (trace_on) - System.err.println("Error ADF0003: " + e); + logger.error("Error ADF0003: " + e); } } else @@ -795,8 +782,7 @@ public byte dfwpnum(double num, int dec) else { retval = GX_ASCDEL_INVALIDSEQUENCE; - if (trace_on) - System.err.println("ADF0004"); + logger.error("ADF0004"); } return retval; } @@ -829,8 +815,7 @@ public byte dfwptxt(String txt, int len) else { retval = GX_ASCDEL_INVALIDSEQUENCE; - if (trace_on) - System.err.println("ADF0004"); + logger.error("ADF0004"); } return retval; } @@ -888,8 +873,7 @@ public byte dfwpdate(Date date, String fmt, String sep) toWrite += day + (i == 2?"":sep); break; default: - if (trace_on) - System.err.println("ADF0012"); + logger.error("ADF0012"); return GX_ASCDEL_BADFMTSTR; } @@ -898,8 +882,7 @@ public byte dfwpdate(Date date, String fmt, String sep) else { retval = GX_ASCDEL_INVALIDSEQUENCE; - if (trace_on) - System.err.println("ADF0004"); + logger.error("ADF0004"); } return retval; } diff --git a/gxmail/src/main/java/com/genexus/internet/POP3Session.java b/gxmail/src/main/java/com/genexus/internet/POP3Session.java index c16f65305..b7a9e0765 100644 --- a/gxmail/src/main/java/com/genexus/internet/POP3Session.java +++ b/gxmail/src/main/java/com/genexus/internet/POP3Session.java @@ -3,11 +3,9 @@ import java.io.BufferedReader; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.PrintStream; import java.io.PrintWriter; import java.net.InetAddress; import java.net.Socket; @@ -18,6 +16,8 @@ import com.genexus.CommonUtil; import com.genexus.common.interfaces.SpecificImplementation; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.diagnostics.core.LogManager; import com.genexus.platform.INativeFunctions; public class POP3Session implements GXInternetConstants,IPOP3Session @@ -26,8 +26,7 @@ public class POP3Session implements GXInternetConstants,IPOP3Session private final int CONN_TLS = 1; private final int CONN_SSL = 2; - private boolean DEBUG = GXInternetConstants.DEBUG; - private PrintStream logOutput; + private static final ILogger logger = LogManager.getLogger(POP3Session.class); private String user; private String password; @@ -56,17 +55,6 @@ public class POP3Session implements GXInternetConstants,IPOP3Session public POP3Session() { - if (DEBUG) - { - try - { - logOutput = new PrintStream(new FileOutputStream(new File("_gx_pop3.log"))); - } - catch (IOException e) - { - System.out.println("Can't open POP3 log file pop3.log"); - } - } } public int error() @@ -392,7 +380,7 @@ private void dele(int i) throws GXMailException private MailMessage retr(int i, String attachmentPath) throws GXMailException { doCommand("RETR " + i); - return new MailMessage(new RFC822Reader(new RFC822EndReader(in, logOutput)), attachmentPath, this.downloadAttachments); + return new MailMessage(new RFC822Reader(new RFC822EndReader(in)), attachmentPath, this.downloadAttachments); } private int getValue(String command) throws GXMailException @@ -429,9 +417,7 @@ private void setError(Exception e) private void log(String text) { - if (DEBUG) - if (logOutput != null) - logOutput.println(text); + logger.debug(text); } protected String doCommand(String commandString) throws GXMailException @@ -440,11 +426,10 @@ protected String doCommand(String commandString) throws GXMailException { if (commandString != null) { - if (DEBUG) - if (!commandString.startsWith("PASS")) - log("OUT : " + commandString); - else - log("OUT : PASS *****"); + if (!commandString.startsWith("PASS")) + log("OUT : " + commandString); + else + log("OUT : PASS *****"); out.print(commandString); out.print(CRLF); @@ -463,8 +448,7 @@ protected String doCommand(String commandString) throws GXMailException if (otherLine != null) { reply = otherLine.trim(); } } - if (DEBUG) - log("IN : " + reply); + log("IN : " + reply); // code change for ver 2.0 wherein there need not // be any error message along with the error reply diff --git a/gxmail/src/main/java/com/genexus/internet/SMTPSession.java b/gxmail/src/main/java/com/genexus/internet/SMTPSession.java index b5fd3c6a7..00ccd62de 100644 --- a/gxmail/src/main/java/com/genexus/internet/SMTPSession.java +++ b/gxmail/src/main/java/com/genexus/internet/SMTPSession.java @@ -5,11 +5,9 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.PrintStream; import java.io.PushbackInputStream; import java.net.InetAddress; import java.net.Socket; @@ -22,6 +20,8 @@ import java.util.StringTokenizer; import java.util.TimeZone; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.diagnostics.core.LogManager; import org.apache.commons.codec.binary.Base64OutputStream; import org.apache.commons.lang.StringUtils; @@ -34,14 +34,12 @@ final class SMTPSession implements GXInternetConstants,ISMTPSession private final int CONN_NORMAL = 0; private final int CONN_TLS = 1; private final int CONN_SSL = 2; - - private boolean DEBUG = GXInternetConstants.DEBUG; + + private static final ILogger logger = LogManager.getLogger(SMTPSession.class); protected String host; protected int port; - private PrintStream logOutput; - private String recipient; private String senderAddress; private String senderName; @@ -81,17 +79,6 @@ final class SMTPSession implements GXInternetConstants,ISMTPSession public SMTPSession() { - if (DEBUG) - { - try - { - logOutput = new PrintStream(new FileOutputStream(new File("_gx_smtp.log"))); - } - catch (IOException e) - { - System.out.println("Can't open SMTP log file smtp.log"); - } - } } public SMTPSession(String host, String senderAddress, String message) throws GXMailException @@ -776,22 +763,12 @@ private String getResponse() throws IOException protected void log(String text) { - if (DEBUG) - if (logOutput != null) - { - logOutput.println(text); - logOutput.flush(); - } + logger.debug(text); } private void logChar(int text) { - if (DEBUG) - if (logOutput != null) - { - logOutput.print((char) text); - logOutput.flush(); - } + logger.debug(Character.toString((char) text)); } } diff --git a/java/src/main/java/com/genexus/Application.java b/java/src/main/java/com/genexus/Application.java index d982b4376..96214b021 100644 --- a/java/src/main/java/com/genexus/Application.java +++ b/java/src/main/java/com/genexus/Application.java @@ -33,7 +33,6 @@ public class Application public static ILogger logger = LogManager.getLogger(Application.class); public static boolean usingQueue = false; - private static final boolean DEBUG = DebugFlag.DEBUG; public static java.lang.Object realMainProgram; public static java.lang.Object nullObject = new Object(); private static final String UNKNOWN_CALLER = ""; @@ -224,8 +223,7 @@ public static void exitApplet() { if (ApplicationContext.getInstance().isMsgsToUI()) { - if (DEBUG) - System.err.println("Exiting VM (1)..."); + logger.debug("Exiting VM (1)..."); onExitCleanup(); @@ -256,8 +254,7 @@ public static void exitAppletOnError() } try { - if (DEBUG) - System.err.println("Exiting VM (2)..."); + logger.debug("Exiting VM (2)..."); System.exit(0); } diff --git a/java/src/main/java/com/genexus/CacheFactory.java b/java/src/main/java/com/genexus/CacheFactory.java index 8ca04f32f..c720cc4f7 100644 --- a/java/src/main/java/com/genexus/CacheFactory.java +++ b/java/src/main/java/com/genexus/CacheFactory.java @@ -14,7 +14,6 @@ public class CacheFactory { private static Object syncRoot = new Object(); private static boolean forceHighestTimetoLive = false; public static String FORCE_HIGHEST_TIME_TO_LIVE = "FORCE_HIGHEST_TIME_TO_LIVE"; - private static final boolean DEBUG = com.genexus.DebugFlag.DEBUG; public static String CACHE_SD = "SD"; public static String CACHE_DB = "DB"; @@ -89,9 +88,7 @@ public static CacheValue createCacheValue(String key, Object[] parms, int cachea public static void restartCache() { if (instance != null) { - if (DEBUG) { - System.err.println("Restarting cache..."); - } + logger.debug("Restarting cache..."); instance.clearAllCaches(); } } diff --git a/java/src/main/java/com/genexus/util/GXServices.java b/java/src/main/java/com/genexus/util/GXServices.java index ea72f1fd2..c777b2556 100644 --- a/java/src/main/java/com/genexus/util/GXServices.java +++ b/java/src/main/java/com/genexus/util/GXServices.java @@ -5,12 +5,14 @@ import com.genexus.ApplicationContext; import com.genexus.ModelContext; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.diagnostics.core.LogManager; import com.genexus.internet.HttpContext; import com.genexus.webpanels.HttpContextWeb; import com.genexus.xml.XMLReader; public class GXServices { - private static final boolean DEBUG = com.genexus.DebugFlag.DEBUG; + private static final ILogger logger = LogManager.getLogger(GXServices.class); public static final String WEBNOTIFICATIONS_SERVICE = "WebNotifications"; public static final String STORAGE_SERVICE = "Storage"; public static final String STORAGE_APISERVICE = "StorageAPI"; @@ -64,9 +66,9 @@ public static void loadFromFile(String basePath, String fileName, GXServices ser } else { - if (!ApplicationContext.getInstance().getReorganization() && DEBUG) + if (!ApplicationContext.getInstance().getReorganization()) { - System.out.println("GXServices - Could not load Services Config: " + fullPath + " - " + reader.getErrDescription()); + logger.debug("GXServices - Could not load Services Config: " + fullPath + " - " + reader.getErrDescription()); } } } diff --git a/java/src/main/java/com/genexus/util/LDAPClient.java b/java/src/main/java/com/genexus/util/LDAPClient.java index cf0d0771d..0c5bd529e 100644 --- a/java/src/main/java/com/genexus/util/LDAPClient.java +++ b/java/src/main/java/com/genexus/util/LDAPClient.java @@ -1,5 +1,8 @@ package com.genexus.util; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.diagnostics.core.LogManager; + import java.util.Hashtable; import java.util.Vector; @@ -15,7 +18,7 @@ import javax.naming.directory.SearchResult; public class LDAPClient { - private static final boolean DEBUG = com.genexus.DebugFlag.DEBUG; + private static final ILogger logger = LogManager.getLogger(LDAPClient.class); String ldapHost; int port; String authentication; @@ -90,11 +93,8 @@ public byte connect() ctx = new InitialDirContext(env); } catch (NamingException e) { - if (DEBUG) - { - System.err.println(e); - } - return 0; + logger.error("Error in connect", e); + return 0; } return 1; @@ -109,10 +109,7 @@ public void disconnect() } catch (NamingException e) { - if (DEBUG) - { - System.err.println(e); - } + logger.error("Error in disconnect", e); } } @@ -142,15 +139,15 @@ public Vector getAttribute(String attName, String context, GXProperties Attribute resultAtt = resultAtts.get(attName); if (resultAtt==null) { - if (DEBUG) - { - System.err.println("Attribute " + attName + " not found"); + if (logger.isErrorEnabled()) + { + logger.error("Attribute " + attName + " not found"); NamingEnumeration validAtts = resultAtts.getIDs(); - System.err.println("Valid attributes are:"); + logger.error("Valid attributes are:"); while (validAtts.hasMoreElements()) { String validAtt = (String) validAtts.next(); - System.err.print(" " + validAtt); + logger.error(" " + validAtt); } } } @@ -165,11 +162,8 @@ public Vector getAttribute(String attName, String context, GXProperties } catch(NamingException e) { - if (DEBUG) - { - System.err.println(e); - } - return strResult; + logger.error("Error in getAttribute", e); + return strResult; } } } diff --git a/java/src/main/java/com/genexus/webpanels/GXWebObjectStub.java b/java/src/main/java/com/genexus/webpanels/GXWebObjectStub.java index ebc7567e7..322aa95a3 100644 --- a/java/src/main/java/com/genexus/webpanels/GXWebObjectStub.java +++ b/java/src/main/java/com/genexus/webpanels/GXWebObjectStub.java @@ -20,8 +20,6 @@ public abstract class GXWebObjectStub extends HttpServlet { public static ILogger logger = null; - private static final boolean DEBUG = DebugFlag.DEBUG; - protected abstract void doExecute(HttpContext context) throws Exception; protected abstract void init(HttpContext context) throws Exception; protected abstract boolean IntegratedSecurityEnabled(); @@ -100,7 +98,7 @@ protected void callExecute(String method, IHttpServletRequest req, IHttpServletR Application.init(gxcfgClass); } httpContext = new HttpContextWeb(method, req, res, getWrappedServletContext()); - if (DEBUG) + if (logger.isDebugEnabled()) dumpRequestInfo(httpContext); boolean useAuthentication = IntegratedSecurityEnabled(); if (!useAuthentication) @@ -206,7 +204,7 @@ else if (IntegratedSecurityLevel() == SECURITY_LOW) if (!res.isCommitted()) res.reset(); logger.error("Web Execution Error", e); - if (DEBUG && httpContext != null) + if (logger.isDebugEnabled() && httpContext != null) dumpRequestInfo(httpContext); throw new ServletException(com.genexus.PrivateUtilities.getStackTraceAsString(e)); } diff --git a/wrappercommon/src/main/java/com/genexus/diagnostics/core/provider/Log4J2Logger.java b/wrappercommon/src/main/java/com/genexus/diagnostics/core/provider/Log4J2Logger.java index c0d2d7b7f..eb824c849 100644 --- a/wrappercommon/src/main/java/com/genexus/diagnostics/core/provider/Log4J2Logger.java +++ b/wrappercommon/src/main/java/com/genexus/diagnostics/core/provider/Log4J2Logger.java @@ -219,5 +219,9 @@ public void trace(String msg, Throwable ex) { public boolean isDebugEnabled() { return log.isDebugEnabled(); } + + public boolean isErrorEnabled() { + return log.isErrorEnabled(); + } } From d9b646a9c8ea771a79bc04e37ea8d797be827950 Mon Sep 17 00:00:00 2001 From: iroqueta Date: Wed, 11 May 2022 19:12:33 -0300 Subject: [PATCH 2/3] Print debug messages in standar classes when GeneXus log is enabled instead of when JDBC log is enabled. Issue: 96165 --- .../com/genexus/diagnostics/core/provider/AndroidLogger.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/android/src/main/java/com/genexus/diagnostics/core/provider/AndroidLogger.java b/android/src/main/java/com/genexus/diagnostics/core/provider/AndroidLogger.java index af0ee4d96..881088ae9 100644 --- a/android/src/main/java/com/genexus/diagnostics/core/provider/AndroidLogger.java +++ b/android/src/main/java/com/genexus/diagnostics/core/provider/AndroidLogger.java @@ -162,4 +162,8 @@ public void trace(String msg, Throwable ex) { public boolean isDebugEnabled() { return true; } + + boolean isErrorEnabled() { + return true; + }; } From dbe462f4210094429f66dcbfdba9f4dd6fd2896a Mon Sep 17 00:00:00 2001 From: iroqueta Date: Wed, 11 May 2022 19:21:04 -0300 Subject: [PATCH 3/3] Print debug messages in standar classes when GeneXus log is enabled instead of when JDBC log is enabled. Issue: 96165 --- .../com/genexus/diagnostics/core/provider/AndroidLogger.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/genexus/diagnostics/core/provider/AndroidLogger.java b/android/src/main/java/com/genexus/diagnostics/core/provider/AndroidLogger.java index 881088ae9..5abd7ce44 100644 --- a/android/src/main/java/com/genexus/diagnostics/core/provider/AndroidLogger.java +++ b/android/src/main/java/com/genexus/diagnostics/core/provider/AndroidLogger.java @@ -163,7 +163,7 @@ public boolean isDebugEnabled() { return true; } - boolean isErrorEnabled() { + public boolean isErrorEnabled() { return true; }; }