* root logger name is now retrieve from context instead of always "".

* log file name at server is prefix by the root logger name from context.
* webui will maintain separate log file prefix by "org.adempiere.webui"
This commit is contained in:
Heng Sin Low 2010-07-19 02:47:34 +08:00
parent 970ae6b62a
commit b4cfb20024
10 changed files with 288 additions and 314 deletions

View File

@ -491,9 +491,8 @@ public final class Adempiere
// Set up Log // Set up Log
CLogMgt.setLevel(Ini.getProperty(Ini.P_TRACELEVEL)); CLogMgt.setLevel(Ini.getProperty(Ini.P_TRACELEVEL));
if (isClient && Ini.isPropertyBool(Ini.P_TRACEFILE) if (isClient && Ini.isPropertyBool(Ini.P_TRACEFILE))
&& CLogFile.get(false, null, isClient) == null) CLogMgt.addHandler(new CLogFile(Ini.findAdempiereHome(), true, isClient));
CLogMgt.addHandler(CLogFile.get (true, Ini.findAdempiereHome(), isClient));
// Set UI // Set UI
if (isClient) if (isClient)

View File

@ -32,31 +32,11 @@ import java.util.logging.LogRecord;
*/ */
public class CLogConsole extends Handler public class CLogConsole extends Handler
{ {
/**
* Get Console Handler
* @param create create if not exists
* @return console hander or null
*/
public static CLogConsole get (boolean create)
{
if (s_console == null && create)
s_console = new CLogConsole();
return s_console;
} // get
private static CLogConsole s_console = null;
/** /**
* Constructor * Constructor
*/ */
public CLogConsole () public CLogConsole ()
{ {
if (s_console == null)
s_console = this;
else
reportError("Console Handler exists already",
new IllegalStateException("Existing Handler"),
ErrorManager.GENERIC_FAILURE);
initialize(); initialize();
} // CLogConsole } // CLogConsole

View File

@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Properties; import java.util.Properties;
import java.util.Vector; import java.util.Vector;
import java.util.logging.ErrorManager;
import java.util.logging.Handler; import java.util.logging.Handler;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.LogRecord; import java.util.logging.LogRecord;
@ -45,33 +44,11 @@ public class CLogErrorBuffer extends Handler
private static final String LOGS_KEY = "org.compiere.util.CLogErrorBuffer.logs"; private static final String LOGS_KEY = "org.compiere.util.CLogErrorBuffer.logs";
/**
* Get Client Log Handler
* @param create create if not exists
* @return handler
*/
public static CLogErrorBuffer get(boolean create)
{
if (s_handler == null && create)
s_handler = new CLogErrorBuffer();
return s_handler;
} // get
/** Appender */
private static CLogErrorBuffer s_handler;
/************************************************************************** /**************************************************************************
* Constructor * Constructor
*/ */
public CLogErrorBuffer () public CLogErrorBuffer ()
{ {
if (s_handler == null)
s_handler = this;
else
reportError("Error Handler exists already",
new IllegalStateException("Existing Handler"),
ErrorManager.GENERIC_FAILURE);
initialize(); initialize();
} // CLogErrorBuffer } // CLogErrorBuffer
@ -454,4 +431,21 @@ public class CLogErrorBuffer extends Handler
return sb.toString (); return sb.toString ();
} // toString } // toString
public static CLogErrorBuffer get(boolean create) {
Handler[] handlers = CLogMgt.getHandlers();
for (Handler handler : handlers)
{
if (handler instanceof CLogErrorBuffer)
return (CLogErrorBuffer) handler;
}
if (create)
{
CLogErrorBuffer handler = new CLogErrorBuffer();
CLogMgt.addHandler(handler);
return handler;
}
return null;
}
} // CLogErrorBuffer } // CLogErrorBuffer

View File

@ -33,22 +33,6 @@ import java.util.logging.LogRecord;
*/ */
public class CLogFile extends Handler public class CLogFile extends Handler
{ {
/**
* Get File Logger
* @param create create if not exists
* @param adempiereHome adempiere home
* @param isClient client
* @return file logger
*/
public static CLogFile get (boolean create, String adempiereHome, boolean isClient)
{
if (s_logFile == null && create)
s_logFile = new CLogFile(adempiereHome, true, isClient);
return s_logFile;
} // get
private static CLogFile s_logFile = null;
/************************************************************************** /**************************************************************************
* Constructor * Constructor
* @param adempiereHome adempiere home * @param adempiereHome adempiere home
@ -57,12 +41,6 @@ public class CLogFile extends Handler
*/ */
public CLogFile (String adempiereHome, boolean createLogDir, boolean isClient) public CLogFile (String adempiereHome, boolean createLogDir, boolean isClient)
{ {
if (s_logFile == null)
s_logFile = this;
else
reportError("File Handler exists already",
new IllegalStateException("Existing Handler"),
ErrorManager.GENERIC_FAILURE);
// //
if (adempiereHome != null && adempiereHome.length() > 0) if (adempiereHome != null && adempiereHome.length() > 0)
m_adempiereHome = adempiereHome; m_adempiereHome = adempiereHome;
@ -162,6 +140,8 @@ public class CLogFile extends Handler
fileName += File.separator; fileName += File.separator;
if (isClient) if (isClient)
fileName += "client"; fileName += "client";
else
fileName += (CLogMgt.getRootLoggerName() +".");
m_fileNameDate = getFileNameDate(System.currentTimeMillis()); m_fileNameDate = getFileNameDate(System.currentTimeMillis());
fileName += m_fileNameDate + "_"; fileName += m_fileNameDate + "_";
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
@ -371,4 +351,20 @@ public class CLogFile extends Handler
return sb.toString (); return sb.toString ();
} // toString } // toString
public static CLogFile get(boolean create, String adempiereHome, boolean isClient) {
Handler[] handlers = CLogMgt.getHandlers();
for (Handler handler : handlers)
{
if (handler instanceof CLogFile)
return (CLogFile) handler;
}
if (create)
{
CLogFile handler = new CLogFile(adempiereHome, true, isClient);
CLogMgt.addHandler(handler);
return handler;
}
return null;
}
} // CLogFile } // CLogFile

View File

@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.jar.Attributes; import java.util.jar.Attributes;
import java.util.jar.Manifest; import java.util.jar.Manifest;
@ -47,15 +48,15 @@ import org.compiere.model.MClient;
*/ */
public class CLogMgt public class CLogMgt
{ {
public static final String DEFAULT_ROOT_LOGGER_NAME = "adempiere";
public static final String ROOT_LOGGER_NAME_PROPERTY = "org.adempiere.log.root";
/** /**
* Initialize Logging * Initialize Logging
* @param isClient client * @param isClient client
*/ */
public static void initialize(boolean isClient) public static void initialize(boolean isClient)
{ {
if (s_handlers != null)
return;
if (isClient) if (isClient)
{ {
LogManager mgr = LogManager.getLogManager(); LogManager mgr = LogManager.getLogManager();
@ -73,18 +74,17 @@ public class CLogMgt
} }
} }
// Create Handler List // Handler List
s_handlers = new ArrayList<Handler>(); List<String>handlerNames = new ArrayList<String>();
try try
{ {
Logger rootLogger = Logger.getLogger(""); Logger rootLogger = Logger.getLogger(getRootLoggerName());
rootLogger.setUseParentHandlers(false);
// System.out.println(rootLogger.getName() + " (" + rootLogger + ")"); // System.out.println(rootLogger.getName() + " (" + rootLogger + ")");
Handler[] handlers = rootLogger.getHandlers(); Handler[] handlers = rootLogger.getHandlers();
for (int i = 0; i < handlers.length; i ++) for (int i = 0; i < handlers.length; i ++)
{ {
// System.out.println(" > " + handlers[i]); handlerNames.add(handlers[i].getClass().getName());
if (!s_handlers.contains(handlers[i]))
s_handlers.add(handlers[i]);
} }
/** /**
Enumeration en = mgr.getLoggerNames(); Enumeration en = mgr.getLoggerNames();
@ -144,21 +144,16 @@ public class CLogMgt
else else
System.err.println(e.toString()); System.err.println(e.toString());
} }
// System.out.println("Handlers=" + s_handlers.size());
// Check Loggers // Check Loggers
if (CLogErrorBuffer.get(false) == null) if (!handlerNames.contains(CLogErrorBuffer.class.getName()))
addHandler(CLogErrorBuffer.get(true)); addHandler(new CLogErrorBuffer());
if (CLogConsole.get(false) == null) if (!handlerNames.contains(CLogConsole.class.getName()))
addHandler(CLogConsole.get(true)); addHandler(new CLogConsole());
CLogFile fh = CLogFile.get (false, null, isClient); if (!handlerNames.contains(CLogFile.class.getName()))
if (fh == null && !isClient)
{ {
fh = CLogFile.get (true, null, isClient); Handler fh = new CLogFile(null, true, isClient);
addHandler(fh); addHandler(fh);
} }
if (fh != null && !isClient)
System.out.println(fh);
setFormatter(CLogFormatter.get()); setFormatter(CLogFormatter.get());
setFilter(CLogFilter.get()); setFilter(CLogFilter.get());
@ -170,10 +165,13 @@ public class CLogMgt
} // initialize } // initialize
/** Handlers */ public static String getRootLoggerName() {
private static ArrayList<Handler> s_handlers = null; String root = Env.getCtx().getProperty(ROOT_LOGGER_NAME_PROPERTY);
/** Current Log Level */ if (root == null || root.trim().length() == 0)
private static Level s_currentLevel = Level.INFO; root = DEFAULT_ROOT_LOGGER_NAME;
return root;
}
/** Logger */ /** Logger */
private static Logger log = Logger.getAnonymousLogger(); private static Logger log = Logger.getAnonymousLogger();
@ -191,9 +189,9 @@ public class CLogMgt
*/ */
protected static Handler[] getHandlers() protected static Handler[] getHandlers()
{ {
Handler[] handlers = new Handler[s_handlers.size()]; Logger rootLogger = Logger.getLogger(getRootLoggerName());
for (int i = 0; i < s_handlers.size(); i++) rootLogger.setUseParentHandlers(false);
handlers[i] = (Handler)s_handlers.get(i); Handler[] handlers = rootLogger.getHandlers();
return handlers; return handlers;
} // getHandlers } // getHandlers
@ -205,10 +203,9 @@ public class CLogMgt
{ {
if (handler == null) if (handler == null)
return; return;
Logger rootLogger = Logger.getLogger(""); Logger rootLogger = Logger.getLogger(getRootLoggerName());
rootLogger.addHandler(handler); rootLogger.addHandler(handler);
// //
s_handlers.add(handler);
log.log(Level.CONFIG, "Handler=" + handler); log.log(Level.CONFIG, "Handler=" + handler);
} // addHandler } // addHandler
@ -219,10 +216,12 @@ public class CLogMgt
*/ */
protected static void setFormatter (java.util.logging.Formatter formatter) protected static void setFormatter (java.util.logging.Formatter formatter)
{ {
for (int i = 0; i < s_handlers.size(); i++) Logger rootLogger = Logger.getLogger(getRootLoggerName());
rootLogger.setUseParentHandlers(false);
Handler[] handlers = rootLogger.getHandlers();
for (int i = 0; i < handlers.length; i++)
{ {
Handler handler = (Handler)s_handlers.get(i); handlers[i].setFormatter(formatter);
handler.setFormatter(formatter);
} }
log.log(Level.CONFIG, "Formatter=" + formatter); log.log(Level.CONFIG, "Formatter=" + formatter);
} // setFormatter } // setFormatter
@ -233,10 +232,12 @@ public class CLogMgt
*/ */
protected static void setFilter (Filter filter) protected static void setFilter (Filter filter)
{ {
for (int i = 0; i < s_handlers.size(); i++) Logger rootLogger = Logger.getLogger(getRootLoggerName());
rootLogger.setUseParentHandlers(false);
Handler[] handlers = rootLogger.getHandlers();
for (int i = 0; i < handlers.length; i++)
{ {
Handler handler = (Handler)s_handlers.get(i); handlers[i].setFilter(filter);
handler.setFilter(filter);
} }
log.log(Level.CONFIG, "Filter=" + filter); log.log(Level.CONFIG, "Filter=" + filter);
} // setFilter } // setFilter
@ -272,23 +273,22 @@ public class CLogMgt
{ {
if (level == null) if (level == null)
return; return;
if (s_handlers == null) Logger rootLogger = Logger.getLogger(getRootLoggerName());
initialize(true); rootLogger.setUseParentHandlers(false);
// Handler[] handlers = rootLogger.getHandlers();
for (int i = 0; i < s_handlers.size(); i++) if (handlers == null || handlers.length == 0)
{ {
Handler handler = (Handler)s_handlers.get(i); initialize(true);
handler.setLevel(level); handlers = rootLogger.getHandlers();
}
//
for (int i = 0; i < handlers.length; i++)
{
handlers[i].setLevel(level);
} }
// JDBC if ALL // JDBC if ALL
setJDBCDebug(s_currentLevel.intValue() == Level.ALL.intValue()); setJDBCDebug(level.intValue() == Level.ALL.intValue());
// //
if (level.intValue() != s_currentLevel.intValue())
{
setLoggerLevel(level, null);
log.config(level.toString());
}
s_currentLevel = level;
} // setHandlerLevel } // setHandlerLevel
/** /**
@ -338,7 +338,8 @@ public class CLogMgt
*/ */
public static Level getLevel() public static Level getLevel()
{ {
return s_currentLevel; Logger rootLogger = Logger.getLogger(getRootLoggerName());
return rootLogger.getLevel();
} // getLevel } // getLevel
/** /**
@ -347,7 +348,8 @@ public class CLogMgt
*/ */
public static int getLevelAsInt() public static int getLevelAsInt()
{ {
return s_currentLevel.intValue(); Logger rootLogger = Logger.getLogger(getRootLoggerName());
return rootLogger.getLevel().intValue();
} // getLevel } // getLevel
/** /**
@ -359,7 +361,7 @@ public class CLogMgt
{ {
if (level == null) if (level == null)
return false; return false;
return level.intValue() >= s_currentLevel.intValue(); return level.intValue() >= getLevelAsInt();
} // isLevel } // isLevel
/** /**
@ -368,7 +370,7 @@ public class CLogMgt
*/ */
public static boolean isLevelAll () public static boolean isLevelAll ()
{ {
return Level.ALL.intValue() == s_currentLevel.intValue(); return Level.ALL.intValue() == getLevelAsInt();
} // isLevelFinest } // isLevelFinest
/** /**
@ -377,7 +379,7 @@ public class CLogMgt
*/ */
public static boolean isLevelFinest () public static boolean isLevelFinest ()
{ {
return Level.FINEST.intValue() >= s_currentLevel.intValue(); return Level.FINEST.intValue() >= getLevelAsInt();
} // isLevelFinest } // isLevelFinest
/** /**
@ -386,7 +388,7 @@ public class CLogMgt
*/ */
public static boolean isLevelFiner () public static boolean isLevelFiner ()
{ {
return Level.FINER.intValue() >= s_currentLevel.intValue(); return Level.FINER.intValue() >= getLevelAsInt();
} // isLevelFiner } // isLevelFiner
/** /**
@ -395,7 +397,7 @@ public class CLogMgt
*/ */
public static boolean isLevelFine () public static boolean isLevelFine ()
{ {
return Level.FINE.intValue() >= s_currentLevel.intValue(); return Level.FINE.intValue() >= getLevelAsInt();
} // isLevelFine } // isLevelFine
/** /**
@ -404,7 +406,7 @@ public class CLogMgt
*/ */
public static boolean isLevelInfo () public static boolean isLevelInfo ()
{ {
return Level.INFO.intValue() >= s_currentLevel.intValue(); return Level.INFO.intValue() >= getLevelAsInt();
} // isLevelFine } // isLevelFine
/** /**
@ -413,13 +415,14 @@ public class CLogMgt
*/ */
public static void enable (boolean enableLogging) public static void enable (boolean enableLogging)
{ {
Logger rootLogger = Logger.getLogger(getRootLoggerName());
rootLogger.setUseParentHandlers(false);
if (enableLogging) if (enableLogging)
setLevel(s_currentLevel); setLevel(rootLogger.getLevel());
else else
{ {
Level level = s_currentLevel;
setLevel(Level.OFF); setLevel(Level.OFF);
s_currentLevel = level;
} }
} // enable } // enable
@ -450,8 +453,7 @@ public class CLogMgt
log.info(description + " - Size=" + p.size() log.info(description + " - Size=" + p.size()
+ ", Hash=" + p.hashCode() + "\n" + getLocalHost()); + ", Hash=" + p.hashCode() + "\n" + getLocalHost());
else else
System.out.println("Log.printProperties = " + description + ", Size=" + p.size() System.out.println("Log.printProperties = " + description + ", Size=" + p.size());
+ ", Hash=" + p.hashCode() + "\n" + getLocalHost());
Object[] pp = p.keySet().toArray(); Object[] pp = p.keySet().toArray();
Arrays.sort(pp); Arrays.sort(pp);

View File

@ -48,8 +48,10 @@ public class CLogger extends Logger implements Serializable
{ {
// CLogMgt.initialize(); // CLogMgt.initialize();
LogManager manager = LogManager.getLogManager(); LogManager manager = LogManager.getLogManager();
if (className == null) if (className == null || className.trim().length() == 0)
className = ""; className = CLogMgt.getRootLoggerName();
else
className = CLogMgt.getRootLoggerName() + "." + className;
Logger result = manager.getLogger(className); Logger result = manager.getLogger(className);
if (result != null && result instanceof CLogger) if (result != null && result instanceof CLogger)
return (CLogger)result; return (CLogger)result;

View File

@ -70,9 +70,6 @@ import org.compiere.swing.CFrame;
*/ */
public final class Env public final class Env
{ {
/** Logging */
private static CLogger s_log = CLogger.getCLogger(Env.class);
private final static ContextProvider clientContextProvider = new DefaultContextProvider(); private final static ContextProvider clientContextProvider = new DefaultContextProvider();
/** /**
@ -98,7 +95,6 @@ public final class Env
} }
// //
reset(true); // final cache reset reset(true); // final cache reset
s_log.info("");
// //
CLogMgt.shutdown(); CLogMgt.shutdown();
// //
@ -128,7 +124,6 @@ public final class Env
*/ */
public static void reset (boolean finalCall) public static void reset (boolean finalCall)
{ {
s_log.info("finalCall=" + finalCall);
if (Ini.isClient()) if (Ini.isClient())
{ {
closeWindows(); closeWindows();
@ -243,7 +238,7 @@ public final class Env
{ {
if (ctx == null || context == null) if (ctx == null || context == null)
return; return;
s_log.finer("Context " + context + "==" + value); getLogger().finer("Context " + context + "==" + value);
// //
if (value == null || value.length() == 0) if (value == null || value.length() == 0)
ctx.remove(context); ctx.remove(context);
@ -251,6 +246,10 @@ public final class Env
ctx.setProperty(context, value); ctx.setProperty(context, value);
} // setContext } // setContext
private static CLogger getLogger() {
return CLogger.getCLogger(Env.class.getName());
}
/** /**
* Set Global Context to Value * Set Global Context to Value
* @param ctx context * @param ctx context
@ -264,7 +263,7 @@ public final class Env
if (value == null) if (value == null)
{ {
ctx.remove(context); ctx.remove(context);
s_log.finer("Context " + context + "==" + value); getLogger().finer("Context " + context + "==" + value);
} }
else else
{ // JDBC Format 2005-05-09 00:00:00.0 { // JDBC Format 2005-05-09 00:00:00.0
@ -272,7 +271,7 @@ public final class Env
// Chop off .0 (nanos) // Chop off .0 (nanos)
stringValue = stringValue.substring(0, stringValue.indexOf(".")); stringValue = stringValue.substring(0, stringValue.indexOf("."));
ctx.setProperty(context, stringValue); ctx.setProperty(context, stringValue);
s_log.finer("Context " + context + "==" + stringValue); getLogger().finer("Context " + context + "==" + stringValue);
} }
} // setContext } // setContext
@ -286,7 +285,7 @@ public final class Env
{ {
if (ctx == null || context == null) if (ctx == null || context == null)
return; return;
s_log.finer("Context " + context + "==" + value); getLogger().finer("Context " + context + "==" + value);
// //
ctx.setProperty(context, String.valueOf(value)); ctx.setProperty(context, String.valueOf(value));
} // setContext } // setContext
@ -314,7 +313,7 @@ public final class Env
if (ctx == null || context == null) if (ctx == null || context == null)
return; return;
if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP) if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP)
s_log.finer("Context("+WindowNo+") " + context + "==" + value); getLogger().finer("Context("+WindowNo+") " + context + "==" + value);
// //
if (value == null || value.equals("")) if (value == null || value.equals(""))
ctx.remove(WindowNo+"|"+context); ctx.remove(WindowNo+"|"+context);
@ -336,7 +335,7 @@ public final class Env
if (value == null) if (value == null)
{ {
ctx.remove(WindowNo+"|"+context); ctx.remove(WindowNo+"|"+context);
s_log.finer("Context("+WindowNo+") " + context + "==" + value); getLogger().finer("Context("+WindowNo+") " + context + "==" + value);
} }
else else
{ // JDBC Format 2005-05-09 00:00:00.0 { // JDBC Format 2005-05-09 00:00:00.0
@ -344,7 +343,7 @@ public final class Env
// Chop off .0 (nanos) // Chop off .0 (nanos)
stringValue = stringValue.substring(0, stringValue.indexOf(".")); stringValue = stringValue.substring(0, stringValue.indexOf("."));
ctx.setProperty(WindowNo+"|"+context, stringValue); ctx.setProperty(WindowNo+"|"+context, stringValue);
s_log.finer("Context("+WindowNo+") " + context + "==" + stringValue); getLogger().finer("Context("+WindowNo+") " + context + "==" + stringValue);
} }
} // setContext } // setContext
@ -360,7 +359,7 @@ public final class Env
if (ctx == null || context == null) if (ctx == null || context == null)
return; return;
if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP) if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP)
s_log.finer("Context("+WindowNo+") " + context + "==" + value); getLogger().finer("Context("+WindowNo+") " + context + "==" + value);
// //
ctx.setProperty(WindowNo+"|"+context, String.valueOf(value)); ctx.setProperty(WindowNo+"|"+context, String.valueOf(value));
} // setContext } // setContext
@ -390,7 +389,7 @@ public final class Env
if (ctx == null || context == null) if (ctx == null || context == null)
return; return;
if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP) if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP)
s_log.finest("Context("+WindowNo+","+TabNo+") " + context + "==" + value); getLogger().finest("Context("+WindowNo+","+TabNo+") " + context + "==" + value);
// //
if (value == null) if (value == null)
if (context.endsWith("_ID")) if (context.endsWith("_ID"))
@ -607,7 +606,7 @@ public final class Env
} }
catch (NumberFormatException e) catch (NumberFormatException e)
{ {
s_log.log(Level.SEVERE, "(" + context + ") = " + s, e); getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
} }
return 0; return 0;
} // getContextAsInt } // getContextAsInt
@ -631,7 +630,7 @@ public final class Env
} }
catch (NumberFormatException e) catch (NumberFormatException e)
{ {
s_log.log(Level.SEVERE, "(" + context + ") = " + s, e); getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
} }
return 0; return 0;
} // getContextAsInt } // getContextAsInt
@ -656,7 +655,7 @@ public final class Env
} }
catch (NumberFormatException e) catch (NumberFormatException e)
{ {
s_log.log(Level.SEVERE, "(" + context + ") = " + s, e); getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
} }
return 0; return 0;
} // getContextAsInt } // getContextAsInt
@ -681,7 +680,7 @@ public final class Env
} }
catch (NumberFormatException e) catch (NumberFormatException e)
{ {
s_log.log(Level.SEVERE, "(" + context + ") = " + s, e); getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
} }
return 0; return 0;
} // getContextAsInt } // getContextAsInt
@ -815,7 +814,7 @@ public final class Env
// JDBC Format YYYY-MM-DD example 2000-09-11 00:00:00.0 // JDBC Format YYYY-MM-DD example 2000-09-11 00:00:00.0
if (s == null || s.equals("")) if (s == null || s.equals(""))
{ {
s_log.log(Level.SEVERE, "No value for: " + context); getLogger().log(Level.SEVERE, "No value for: " + context);
return new Timestamp(System.currentTimeMillis()); return new Timestamp(System.currentTimeMillis());
} }
@ -1068,7 +1067,7 @@ public final class Env
} }
catch (SQLException e) catch (SQLException e)
{ {
s_log.log(Level.SEVERE, "", e); getLogger().log(Level.SEVERE, "", e);
} }
finally { finally {
DB.close(rs, pstmt); DB.close(rs, pstmt);
@ -1080,7 +1079,7 @@ public final class Env
// No Language - set to System // No Language - set to System
if (AD_Languages.size() == 0) if (AD_Languages.size() == 0)
{ {
s_log.warning ("NO System Language - Set to Base " + Language.getBaseAD_Language()); getLogger().warning ("NO System Language - Set to Base " + Language.getBaseAD_Language());
language.setAD_Language(Language.getBaseAD_Language()); language.setAD_Language(Language.getBaseAD_Language());
return; return;
} }
@ -1093,7 +1092,7 @@ public final class Env
String langCompare = language.getAD_Language().substring(0, 2); String langCompare = language.getAD_Language().substring(0, 2);
if (lang.equals(langCompare)) if (lang.equals(langCompare))
{ {
s_log.fine("Found similar Language " + AD_Language); getLogger().fine("Found similar Language " + AD_Language);
language.setAD_Language(AD_Language); language.setAD_Language(AD_Language);
return; return;
} }
@ -1102,7 +1101,7 @@ public final class Env
// We found same language // We found same language
// if (!"0".equals(Msg.getMsg(AD_Language, "0"))) // if (!"0".equals(Msg.getMsg(AD_Language, "0")))
s_log.warning ("Not System Language=" + language getLogger().warning ("Not System Language=" + language
+ " - Set to Base Language " + Language.getBaseAD_Language()); + " - Set to Base Language " + Language.getBaseAD_Language());
language.setAD_Language(Language.getBaseAD_Language()); language.setAD_Language(Language.getBaseAD_Language());
} // verifyLanguage } // verifyLanguage
@ -1226,7 +1225,7 @@ public final class Env
int j = inStr.indexOf('@'); // next @ int j = inStr.indexOf('@'); // next @
if (j < 0) if (j < 0)
{ {
s_log.log(Level.SEVERE, "No second tag: " + inStr); getLogger().log(Level.SEVERE, "No second tag: " + inStr);
return ""; // no second tag return ""; // no second tag
} }
@ -1237,7 +1236,7 @@ public final class Env
ctxInfo = getContext(ctx, token); // get global context ctxInfo = getContext(ctx, token); // get global context
if (ctxInfo.length() == 0) if (ctxInfo.length() == 0)
{ {
s_log.config("No Context Win=" + WindowNo + " for: " + token); getLogger().config("No Context Win=" + WindowNo + " for: " + token);
if (!ignoreUnparsable) if (!ignoreUnparsable)
return ""; // token not found return ""; // token not found
} }
@ -1291,7 +1290,7 @@ public final class Env
int j = inStr.indexOf('@'); // next @ int j = inStr.indexOf('@'); // next @
if (j < 0) if (j < 0)
{ {
s_log.log(Level.SEVERE, "No second tag: " + inStr); getLogger().log(Level.SEVERE, "No second tag: " + inStr);
return ""; // no second tag return ""; // no second tag
} }
@ -1410,7 +1409,7 @@ public final class Env
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, e.toString()); getLogger().log(Level.SEVERE, e.toString());
} }
return retValue; return retValue;
} // getWindow } // getWindow
@ -1513,7 +1512,7 @@ public final class Env
// URL url = Adempiere.class.getResource("images/" + fileNameInImageDir); // URL url = Adempiere.class.getResource("images/" + fileNameInImageDir);
if (url == null) if (url == null)
{ {
s_log.log(Level.SEVERE, "Not found: " + fileNameInImageDir); getLogger().log(Level.SEVERE, "Not found: " + fileNameInImageDir);
return null; return null;
} }
Toolkit tk = Toolkit.getDefaultToolkit(); Toolkit tk = Toolkit.getDefaultToolkit();
@ -1533,7 +1532,7 @@ public final class Env
// URL url = Adempiere.class.getResource("images/" + fileNameInImageDir); // URL url = Adempiere.class.getResource("images/" + fileNameInImageDir);
if (url == null) if (url == null)
{ {
s_log.log(Level.INFO, "Not found: " + fileNameInImageDir); getLogger().log(Level.INFO, "Not found: " + fileNameInImageDir);
return null; return null;
} }
return new ImageIcon(url); return new ImageIcon(url);
@ -1558,7 +1557,7 @@ public final class Env
// url = Adempiere.class.getResource("images/" + fileName+".png"); // url = Adempiere.class.getResource("images/" + fileName+".png");
if (url == null) if (url == null)
{ {
s_log.log(Level.INFO, "GIF/PNG Not found: " + fileName); getLogger().log(Level.INFO, "GIF/PNG Not found: " + fileName);
return null; return null;
} }
return new ImageIcon(url); return new ImageIcon(url);
@ -1571,7 +1570,7 @@ public final class Env
*/ */
public static void startBrowser (String url) public static void startBrowser (String url)
{ {
s_log.info(url); getLogger().info(url);
getContextProvider().showURL(url); getContextProvider().showURL(url);
} // startBrowser } // startBrowser
@ -1615,7 +1614,7 @@ public final class Env
for (int i = 0; i < s_hiddenWindows.size(); i++) for (int i = 0; i < s_hiddenWindows.size(); i++)
{ {
CFrame hidden = s_hiddenWindows.get(i); CFrame hidden = s_hiddenWindows.get(i);
s_log.info(i + ": " + hidden); getLogger().info(i + ": " + hidden);
if (hidden.getAD_Window_ID() == window.getAD_Window_ID()) if (hidden.getAD_Window_ID() == window.getAD_Window_ID())
return false; // already there return false; // already there
} }
@ -1624,7 +1623,7 @@ public final class Env
if (s_hiddenWindows.add(window)) if (s_hiddenWindows.add(window))
{ {
window.setVisible(false); window.setVisible(false);
s_log.info(window.toString()); getLogger().info(window.toString());
// window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_ICONIFIED)); // window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_ICONIFIED));
if (s_hiddenWindows.size() > 10) { if (s_hiddenWindows.size() > 10) {
CFrame toClose = s_hiddenWindows.remove(0); // sort of lru CFrame toClose = s_hiddenWindows.remove(0); // sort of lru
@ -1654,7 +1653,7 @@ public final class Env
if (hidden.getAD_Window_ID() == AD_Window_ID) if (hidden.getAD_Window_ID() == AD_Window_ID)
{ {
s_hiddenWindows.remove(i); s_hiddenWindows.remove(i);
s_log.info(hidden.toString()); getLogger().info(hidden.toString());
hidden.setVisible(true); hidden.setVisible(true);
// De-iconify window - teo_sarca [ 1707221 ] // De-iconify window - teo_sarca [ 1707221 ]
int state = hidden.getExtendedState(); int state = hidden.getExtendedState();
@ -1689,16 +1688,16 @@ public final class Env
*/ */
public static void sleep (int sec) public static void sleep (int sec)
{ {
s_log.info("Start - Seconds=" + sec); getLogger().info("Start - Seconds=" + sec);
try try
{ {
Thread.sleep(sec*1000); Thread.sleep(sec*1000);
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.WARNING, "", e); getLogger().log(Level.WARNING, "", e);
} }
s_log.info("End"); getLogger().info("End");
} // sleep } // sleep
/** /**

View File

@ -95,9 +95,8 @@ public final class AdempiereClient
// Set up Log // Set up Log
CLogMgt.setLevel(Ini.getProperty(Ini.P_TRACELEVEL)); CLogMgt.setLevel(Ini.getProperty(Ini.P_TRACELEVEL));
if (isClient && Ini.isPropertyBool(Ini.P_TRACEFILE) if (isClient && Ini.isPropertyBool(Ini.P_TRACEFILE))
&& CLogFile.get(false, null, isClient) == null) CLogMgt.addHandler(new CLogFile(Ini.findAdempiereHome(), true, isClient));
CLogMgt.addHandler(CLogFile.get (true, Ini.findAdempiereHome(), isClient));
// Set UI // Set UI
if (isClient) if (isClient)

View File

@ -22,6 +22,7 @@ import java.util.Properties;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.compiere.util.CLogMgt;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.zkoss.util.Locales; import org.zkoss.util.Locales;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
@ -80,7 +81,7 @@ public class SessionContextListener implements ExecutionInit,
SessionManager.getAppDesktop().showURL(url, true); SessionManager.getAppDesktop().showURL(url, true);
} }
}); });
ctx.put(CLogMgt.ROOT_LOGGER_NAME_PROPERTY, "org.adempiere.webui");
ctx.setProperty(SERVLET_SESSION_ID, httpSession.getId()); ctx.setProperty(SERVLET_SESSION_ID, httpSession.getId());
session.setAttribute(SESSION_CTX, ctx); session.setAttribute(SESSION_CTX, ctx);
} }

View File

@ -33,6 +33,7 @@ import org.adempiere.webui.window.ZkReportViewerProvider;
import org.compiere.Adempiere; import org.compiere.Adempiere;
import org.compiere.print.ReportCtl; import org.compiere.print.ReportCtl;
import org.compiere.report.ReportStarter; import org.compiere.report.ReportStarter;
import org.compiere.util.CLogMgt;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Ini; import org.compiere.util.Ini;
import org.zkoss.zk.ui.http.DHtmlLayoutServlet; import org.zkoss.zk.ui.http.DHtmlLayoutServlet;
@ -69,6 +70,7 @@ public class WebUIServlet extends DHtmlLayoutServlet
SessionManager.getAppDesktop().showURL(url, true); SessionManager.getAppDesktop().showURL(url, true);
} }
}); });
serverContext.put(CLogMgt.ROOT_LOGGER_NAME_PROPERTY, "org.adempiere.webui");
ServerContext.setCurrentInstance(serverContext); ServerContext.setCurrentInstance(serverContext);
boolean started = Adempiere.startup(false); boolean started = Adempiere.startup(false);