/** The log handler. */
private static final LogHandler logHandler = new LogHandler();
+ static {
+ logHandler.setLevel(Level.ALL);
+ }
+
+ /** The root name of the hierarchy. */
+ private static String hierarchyRootName;
+
/**
* Adds a listener to the log handler.
*
/**
* Sets up logging and installs the log handler.
+ *
+ * @param hierarchyName
+ * The name of the hierarchy root logger
*/
- public static void setup() {
- Logger rootLogger = Logger.getAnonymousLogger().getParent();
+ public static void setup(String hierarchyName) {
+ hierarchyRootName = hierarchyName;
+ Logger rootLogger = Logger.getLogger(hierarchyName);
rootLogger.addHandler(logHandler);
+ rootLogger.setUseParentHandlers(false);
rootLogger.setLevel(Level.ALL);
- logHandler.setLevel(Level.INFO);
+ }
+
+ /**
+ * Returns a named logger from the jSite hierarchy.
+ *
+ * @param name
+ * The name of the logger
+ * @return The logger
+ */
+ public static Logger getLogger(String name) {
+ Logger logger = Logger.getLogger(hierarchyRootName + "." + name);
+ return logger;
}
/**
* Package-private constructor.
*/
LogHandler() {
+ /* do nothing. */
}
/** The list of the listeners. */
*/
@Override
public void close() throws SecurityException {
+ /* do nothing. */
}
/**
*/
@Override
public void flush() {
+ /* do nothing. */
}
/**