/** * Shortcut that returns the LevelFactory */ public static LevelFactory getLevelFactory() { return (LevelFactory) getLoggerFactory(); }
/** * Configure Logger. * @param file The configuration file for monolog (usually: trace.properties) */ public static void configure(final String file) { configFile = file; getLoggerFactory(); if (!clientcontainer) { // TODO find a good place for this initialization // to allow using Monolog when want traces of P6Spy usage in SQL requests //P6SpyLogger.logger = lf.getLogger(SPY_LOGGER_NAME); // ----------- // Comment out call until JONAS uses Log4j // TraceTm.configure(lf); } }
/** * Shortcut to get the Logger by its topic name. * @param topic the topic of the returned logger * @return always a logger instance (never null value). */ public static Logger getLogger(final String topic) { return getLoggerFactory().getLogger(topic); }
/** * Get the topics list. Assumes that all Loggers are TopicalLoggers. * @return the topics list. */ public String[] getTopics() { Logger[] logs = Log.getLoggerFactory().getLoggers(); // put names in alphabetical order TreeSet<String> tset = new TreeSet<String>(); for (int i = 0; i < logs.length; i++) { tset.add(logs[i].getName()); } return tset.toArray(new String[0]); }
/** * @return the topics list. Assumes that all Loggers are TopicalLoggers. */ public String[] getTopics() { Logger[] logs = Log.getLoggerFactory().getLoggers(); // put names in alphabetical order TreeSet tset = new TreeSet(); for (int i = 0; i < logs.length; i++) { tset.add(logs[i].getName()); } return (String[]) tset.toArray(new String[0]); }
/** * Returns the standard PrintWriter associated to the logger defined by * its topic. * This is mainly used for DBM and Connectors. */ public static PrintWriter getLogWriter(final String topic) { // TODO : should not create a new object at each call return new PrintWriterImpl(getLogger(topic), getLoggerFactory()); }
/** * @return list of properties for logging system */ public Properties getProperties() { Properties props = Log.getProperties(); if (props == null) { Log.getLoggerFactory(); props = Log.getProperties(); } return props; }
/** * Returns the names of the Monolog handlers * @return The handler names defines in Monolog */ public String[] getHandlerNames() { LoggerFactory lf = Log.getLoggerFactory(); if (lf instanceof HandlerFactory) { HandlerFactory mf = (HandlerFactory) lf; Handler[] hs = mf.getHandlers(); String[] hns = new String[hs.length]; for (int i = 0; i < hs.length; i++) { hns[i] = hs[i].getName(); } return hns; } return null; }
/** * Getter for the map of the attributes of a handler. * @param handlername the handler name * @return The map of the attributes defines for the handler */ public Map getHandlerAttributes(final String handlername) { LoggerFactory lf = Log.getLoggerFactory(); if (lf instanceof HandlerFactory) { HandlerFactory mf = (HandlerFactory) lf; Handler h = mf.getHandler(handlername); String[] ans = h.getAttributeNames(); Map m = new HashMap(ans.length); for (int i = 0; i < ans.length; i++) { m.put(ans[i], h.getAttribute(ans[i])); } return m; } return null; }
/** * Return a topic's level * @param topic the topic we need ti know its level * @return the topic's level */ public String getTopicLevel(final String topic) { Logger topicLogger = Log.getLoggerFactory().getLogger(topic); Level lev = topicLogger.getCurrentLevel(); return lev.getName(); }
/** * Return a topic's level. * @param topic the topic we need to know its level * @return the topic's level */ public String getTopicLevel(final String topic) { Logger topicLogger = Log.getLoggerFactory().getLogger(topic); Level lev = topicLogger.getCurrentLevel(); return lev.getName(); }
/** * set Topic Level * @param topic topic to set * @param level the level to set */ public void setTopicLevel(final String topic, final String level) { Logger topicLogger = Log.getLoggerFactory().getLogger(topic); Level lev = Log.getLevelFactory().getLevel(level); // must check null (bug monolog) if (lev != null) { topicLogger.setLevel(lev); } else { // TO DO maybe a better error treatement could be found throw new RuntimeException("Unknown level " + level); } // the modified property name is 'logger.topic.level' String propName = "logger." + topic + ".level"; // Send a notification containing the new value of this property to the // listner MBean sendReconfigNotification(++sequenceNumber, SERVICE_NAME, new PropertiesConfigurationData(propName, level)); }
/** * set Topic Level * @param topic topic to set * @param level the level to set */ public void setTopicLevel(final String topic, final String level) { Logger topicLogger = Log.getLoggerFactory().getLogger(topic); Level lev = Log.getLevelFactory().getLevel(level); // must check null (bug monolog) if (lev != null) { topicLogger.setLevel(lev); } else { // TO DO maybe a better error treatement could be found throw new RuntimeException("Unknown level " + level); } // the modified property name is 'logger.topic.level' String propName = "logger." + topic + ".level"; // Send a notification containing the new value of this property to the // listener MBean sendReconfigNotification(++sequenceNumber, SERVICE_NAME, new PropertiesConfigurationData(propName, level)); }