Bob Scheifler wrote On 05/21/07 12:57,:
> 
>>Do I need to restart my JavaSpace stack for this?
> 
> 
> If you can connect to it with jconsole, you should be able to
> change the logging level on the fly.  But that won't help if
> you're using the default ConsoleHandler configuration, as it
> restricts to only INFO and above, and I don't think you can
> change it via jconsole.
> 

If you are running the JavaSpace on JDK 6, you can use the attach API to load an
agent into the JavaSpace VM and tell the LogManager to reinitialize its
configuration with one that has the desired Handler/Logger levels set.

For example in your agentmain method you would do something along the lines of:

    public static void agentmain(String agentArgs, Instrumentation inst)
        throws Exception
    {

        LogManager lm = LogManager.getLogManager();

        lm.readConfiguration(
            new FileInputStream("<<path to your new logging config file>>"));
    }


To load the agent into the JavaSpace VM you would write something along the
lines of:

    public static void main(String[] args)
        throws AgentInitializationException, AgentLoadException,
            AttachNotSupportedException
    {

        VirtualMachine vm = VirtualMachine.attach("<<PID of JavaSpace VM>>");
        vm.loadAgent("<<path to agent jar>>");
    }


Your agent needs to be packaged in a jar file containing a manifest with the
Agent-Class entry specifying the name of your agent class.


> - Bob
> 

Reply via email to