/** * Constructor. * @param id id of the context. */ public ComponentContext(final String id) { myEnv = new Hashtable<String, Object>(); compId = id; logger = Log.getLogger(Log.JONAS_NAMING_PREFIX); }
/** * 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; }
/** * Shortcut that returns the LevelFactory */ public static LevelFactory getLevelFactory() { return (LevelFactory) getLoggerFactory(); }
/** * 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)); }
/** * Start bundle. * @throws Exception could not start bundle. */ public void start() throws Exception { logger.debug("Starting jonas-mbeans bundle..."); // Get domainName and serverName from the Bootstrap service // Got all we need to create and register JSR77 MBeans try { domainName = serverProperties.getDomainName(); serverName = serverProperties.getServerName(); // set configuration info into the Log System (monolog) String logConfigFileName = serverProperties.getValue(LOG_CONFIGFILE, DEF_LOG_CONFIGFILE); org.ow2.jonas.lib.util.Log.configure(logConfigFileName); Properties logProperties = org.ow2.jonas.lib.util.Log.getProperties(); logConfigFile = org.ow2.jonas.lib.util.Log.getConfigFileName(); ((J2EEServer) j2eeServer).setServiceManager(serviceManager); ((J2EEServer) j2eeServer).setConfigManager(configurationManager); registerMBeans(serverProperties, logProperties); } catch (MalformedObjectNameException me) { logger.error("Failed to register mbeans: " + me.getMessage()); return; } catch (Exception e) { logger.error("Failed to register mbeans" + e.getMessage()); return; } }
/** * Super charge of the methode to take advantage of JMX notification * offered by Monolog 2.0 * @param arg0 The notification Listener * @param arg1 The notification Filter * @param arg2 Handback object */ public void addNotificationListener(NotificationListener arg0 , NotificationFilter arg1, final Object arg2) { // Get jmx handler, if any Handler handler = Log.getJmxHandler(); if (handler != null && (handler instanceof NotificationEmitter)) { // Add arg0 as listener to notifications emitted by the jmx handler ((NotificationEmitter) handler).addNotificationListener(arg0, arg1, arg2); } // If the listener is the ReconfigManager, the following // instruction allows the ReconfigManager to treat the reconfiguration notifications // emitted by the LogManager super.addNotificationListener(arg0, arg1, arg2); } }
/** * 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); } }
/** * 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)); }
/** * Constructor. * @param id id of the context. * @param env initial environment. */ public ComponentContext(final String id, final Hashtable env) { if (env != null) { // clone env to be able to change it. myEnv = (Hashtable) (env.clone()); } compId = id; logger = Log.getLogger(Log.JONAS_NAMING_PREFIX); }
/** * 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); }
/** * Set the given log level to the specified logger. * @param loggerName name of the loger to be configured * @param level target level * @return the previous level of the logger */ public static Level setComponentLogLevel(final String loggerName, final Level level) { Logger log = Log.getLogger(loggerName); Level old = log.getCurrentLevel(); log.setLevel(level); return old; }
/** * 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]); }
/** * Construct a reconfigurator for a JOnAS service or a JOnAS resource. * @param name Name of the JOnAS service or JOnAS resource to which this object is associated * @param configFileName name of the config file */ public BaseConfigurationActuator(final String name, final String configFileName) { // Get a logger for server traces logger = Log.getLogger(Log.JONAS_MANAGEMENT_PREFIX); this.name = name; this.configFileName = configFileName; this.lastSequence = 0; if (logger.isLoggable(BasicLevel.DEBUG)) { logger.log(BasicLevel.DEBUG, "Creating IConfigurationActuator for " + name + " - configuration file is " + configFileName); } }
/** * @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]); }
/** * Construct JavaVM MBean. * @param pObjectName The MBean's OBJECT_NAME * @param props the JOnAS server's configuration properties. */ public JavaVm(final String pObjectName, final ServerProperties props) { super(pObjectName); javaVersion = props.getValue(JAVA_VERSION); javaVendor = props.getValue(JAVA_VM_NAME) + "-" + props.getValue(JAVA_VM_VERSION) + " / " + props.getValue(JAVA_VENDOR); javaHome = props.getValue(JAVA_HOME); try { java.net.InetAddress oInet = java.net.InetAddress.getLocalHost(); node = oInet.getCanonicalHostName(); } catch (java.net.UnknownHostException e) { node = NODE_LOCAL; } // get a logger for server traces sLogger = Log.getLogger(Log.JONAS_SERVER_PREFIX); }
/** * 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; }
logger = Log.getLogger(Log.JONAS_SECURITY_PREFIX);
/** * 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; }
private static Logger logger = Log.getLogger("org.ow2.jonas.deployment.ejb");