You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Carsten Hammer <ca...@t-online.de> on 2004/01/30 23:24:18 UTC

how to use sawchain2?

Hi,
I tried to instantiate ChainsawCentral like this:

import java.awt.*;
import javax.swing.*;
import org.apache.log4j.chainsaw.plugins.*;

public class LoggingDialog extends JDialog {
   private JPanel panel1 = new JPanel();
   private BorderLayout borderLayout1 = new BorderLayout();
   private ChainsawCentral chainsaw = new 
org.apache.log4j.chainsaw.plugins.ChainsawCentral();


   public LoggingDialog(Frame frame, String title, boolean modal) {
     super(frame, title, modal);
     try {
       jbInit();
       pack();
     }
     catch(Exception ex) {
       ex.printStackTrace();
     }
   }

   public LoggingDialog() {
     this(null, "", false);
   }
   private void jbInit() throws Exception {

     panel1.setLayout(borderLayout1);
     getContentPane().add(panel1);
     panel1.add(chainsaw, BorderLayout.NORTH);

   }
}

Unfortunatly it does not work. I get the Dialog but there are no logs 
written to it.
I tried doing things like

BasicConfigurator.configure(new 
org.apache.log4j.chainsaw.ChainsawAppender());
org.apache.log4j.Logger.getRootLogger().addAppender(new 
org.apache.log4j.chainsaw.ChainsawAppender());

before and added a org.apache.log4j.netSocketAppender to my 
log4j.properties nothing helped.

This all using log4j-1.3alpha.jar and log4j-chainsaw-1.3alpha.jar.

Has anybody here been able to use chainsaw within a custom application?
How?
Best regards,
Carsten



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: how to use sawchain2?

Posted by Paul Smith <pa...@lawlex.com.au>.
> One strange thing I experienced is that this:
> 
>   org.apache.log4j.chainsaw.ApplicationPreferenceModel model = new 
> org.apache.log4j.chainsaw.ApplicationPreferenceModel();
> 
> org.apache.log4j.chainsaw.LogUI.createChainsawGUI(model,null);
> 
> gives me a
> 
> java.lang.IllegalArgumentException: timeout value is negative
> 
> 	at java.lang.Object.wait(Native Method)
> 
> 	at 
> org.apache.log4j.chainsaw.ChainsawAppenderHandler$WorkQueue$WorkerThread.run(Unknown 
> Source)
> 

Sounds like the default value of that property in the
ApplicationPreferenceModel is not set correctly.  You have correctly
worked out to use the SettingsManager to configure it with the defaults.

> Does there exist Hello World sourcecode that uses Chainsaw as a 
> loggerviewer that I could get?

Unfortunately there is not at this stage, I think your's might be the
first one! 

cheers, 

Paul Smith


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: how to use sawchain2?

Posted by Paul Smith <pa...@lawlex.com.au>.
> One strange thing I experienced is that this:
> 
>   org.apache.log4j.chainsaw.ApplicationPreferenceModel model = new 
> org.apache.log4j.chainsaw.ApplicationPreferenceModel();
> 
> org.apache.log4j.chainsaw.LogUI.createChainsawGUI(model,null);
> 
> gives me a
> 
> java.lang.IllegalArgumentException: timeout value is negative
> 
> 	at java.lang.Object.wait(Native Method)
> 
> 	at 
> org.apache.log4j.chainsaw.ChainsawAppenderHandler$WorkQueue$WorkerThread.run(Unknown 
> Source)
> 

Sounds like the default value of that property in the
ApplicationPreferenceModel is not set correctly.  You have correctly
worked out to use the SettingsManager to configure it with the defaults.

> Does there exist Hello World sourcecode that uses Chainsaw as a 
> loggerviewer that I could get?

Unfortunately there is not at this stage, I think your's might be the
first one! 

cheers, 

Paul Smith


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: how to use sawchain2?

Posted by Carsten Hammer <Ca...@t-online.de>.
One strange thing I experienced is that this:

  org.apache.log4j.chainsaw.ApplicationPreferenceModel model = new 
org.apache.log4j.chainsaw.ApplicationPreferenceModel();

org.apache.log4j.chainsaw.LogUI.createChainsawGUI(model,null);

gives me a

java.lang.IllegalArgumentException: timeout value is negative

	at java.lang.Object.wait(Native Method)

	at 
org.apache.log4j.chainsaw.ChainsawAppenderHandler$WorkQueue$WorkerThread.run(Unknown 
Source)

and all events but the first are missing while this one


org.apache.log4j.chainsaw.ApplicationPreferenceModel model = new 
org.apache.log4j.chainsaw.ApplicationPreferenceModel();
 
org.apache.log4j.chainsaw.prefs.SettingsManager.getInstance().configure(model);

  org.apache.log4j.chainsaw.LogUI.createChainsawGUI(model,null);

seems to work.

Does there exist Hello World sourcecode that uses Chainsaw as a 
loggerviewer that I could get?

Best regards,
Carsten

Paul Smith schrieb:
> Try:
> 
> org.apache.log4j.chainsaw.LogUI.createChainsawGUI(ApplicationPreferenceModel model,
>     Action shutdownAction) 
> 
> method.
> 
> You will need an instance of the ApplicationPreferenceModel (create a
> blank one in code and customise it if you need it) and a Swing Action
> that can handle when the user chooses to "exit" chainsaw. 
> 
> The default action will exit the VM so you should provide an Action that
> hides the LogUI frame.  You will also then need in your app a way to
> make the LogUI frame visible again.
> 
> cheers,
> 
> Paul Smith
> 
> 
> On Sat, 2004-01-31 at 09:24, Carsten Hammer wrote:
> 
>>Hi,
>>I tried to instantiate ChainsawCentral like this:
>>
>>import java.awt.*;
>>import javax.swing.*;
>>import org.apache.log4j.chainsaw.plugins.*;
>>
>>public class LoggingDialog extends JDialog {
>>   private JPanel panel1 = new JPanel();
>>   private BorderLayout borderLayout1 = new BorderLayout();
>>   private ChainsawCentral chainsaw = new 
>>org.apache.log4j.chainsaw.plugins.ChainsawCentral();
>>
>>
>>   public LoggingDialog(Frame frame, String title, boolean modal) {
>>     super(frame, title, modal);
>>     try {
>>       jbInit();
>>       pack();
>>     }
>>     catch(Exception ex) {
>>       ex.printStackTrace();
>>     }
>>   }
>>
>>   public LoggingDialog() {
>>     this(null, "", false);
>>   }
>>   private void jbInit() throws Exception {
>>
>>     panel1.setLayout(borderLayout1);
>>     getContentPane().add(panel1);
>>     panel1.add(chainsaw, BorderLayout.NORTH);
>>
>>   }
>>}
>>
>>Unfortunatly it does not work. I get the Dialog but there are no logs 
>>written to it.
>>I tried doing things like
>>
>>BasicConfigurator.configure(new 
>>org.apache.log4j.chainsaw.ChainsawAppender());
>>org.apache.log4j.Logger.getRootLogger().addAppender(new 
>>org.apache.log4j.chainsaw.ChainsawAppender());
>>
>>before and added a org.apache.log4j.netSocketAppender to my 
>>log4j.properties nothing helped.
>>
>>This all using log4j-1.3alpha.jar and log4j-chainsaw-1.3alpha.jar.
>>
>>Has anybody here been able to use chainsaw within a custom application?
>>How?
>>Best regards,
>>Carsten
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>>For additional commands, e-mail: log4j-dev-help@logging.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: how to use sawchain2?

Posted by Paul Smith <pa...@lawlex.com.au>.
Try:

org.apache.log4j.chainsaw.LogUI.createChainsawGUI(ApplicationPreferenceModel model,
    Action shutdownAction) 

method.

You will need an instance of the ApplicationPreferenceModel (create a
blank one in code and customise it if you need it) and a Swing Action
that can handle when the user chooses to "exit" chainsaw. 

The default action will exit the VM so you should provide an Action that
hides the LogUI frame.  You will also then need in your app a way to
make the LogUI frame visible again.

cheers,

Paul Smith


On Sat, 2004-01-31 at 09:24, Carsten Hammer wrote:
> Hi,
> I tried to instantiate ChainsawCentral like this:
> 
> import java.awt.*;
> import javax.swing.*;
> import org.apache.log4j.chainsaw.plugins.*;
> 
> public class LoggingDialog extends JDialog {
>    private JPanel panel1 = new JPanel();
>    private BorderLayout borderLayout1 = new BorderLayout();
>    private ChainsawCentral chainsaw = new 
> org.apache.log4j.chainsaw.plugins.ChainsawCentral();
> 
> 
>    public LoggingDialog(Frame frame, String title, boolean modal) {
>      super(frame, title, modal);
>      try {
>        jbInit();
>        pack();
>      }
>      catch(Exception ex) {
>        ex.printStackTrace();
>      }
>    }
> 
>    public LoggingDialog() {
>      this(null, "", false);
>    }
>    private void jbInit() throws Exception {
> 
>      panel1.setLayout(borderLayout1);
>      getContentPane().add(panel1);
>      panel1.add(chainsaw, BorderLayout.NORTH);
> 
>    }
> }
> 
> Unfortunatly it does not work. I get the Dialog but there are no logs 
> written to it.
> I tried doing things like
> 
> BasicConfigurator.configure(new 
> org.apache.log4j.chainsaw.ChainsawAppender());
> org.apache.log4j.Logger.getRootLogger().addAppender(new 
> org.apache.log4j.chainsaw.ChainsawAppender());
> 
> before and added a org.apache.log4j.netSocketAppender to my 
> log4j.properties nothing helped.
> 
> This all using log4j-1.3alpha.jar and log4j-chainsaw-1.3alpha.jar.
> 
> Has anybody here been able to use chainsaw within a custom application?
> How?
> Best regards,
> Carsten
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: how to use sawchain2?

Posted by Paul Smith <pa...@lawlex.com.au>.
Try:

org.apache.log4j.chainsaw.LogUI.createChainsawGUI(ApplicationPreferenceModel model,
    Action shutdownAction) 

method.

You will need an instance of the ApplicationPreferenceModel (create a
blank one in code and customise it if you need it) and a Swing Action
that can handle when the user chooses to "exit" chainsaw. 

The default action will exit the VM so you should provide an Action that
hides the LogUI frame.  You will also then need in your app a way to
make the LogUI frame visible again.

cheers,

Paul Smith


On Sat, 2004-01-31 at 09:24, Carsten Hammer wrote:
> Hi,
> I tried to instantiate ChainsawCentral like this:
> 
> import java.awt.*;
> import javax.swing.*;
> import org.apache.log4j.chainsaw.plugins.*;
> 
> public class LoggingDialog extends JDialog {
>    private JPanel panel1 = new JPanel();
>    private BorderLayout borderLayout1 = new BorderLayout();
>    private ChainsawCentral chainsaw = new 
> org.apache.log4j.chainsaw.plugins.ChainsawCentral();
> 
> 
>    public LoggingDialog(Frame frame, String title, boolean modal) {
>      super(frame, title, modal);
>      try {
>        jbInit();
>        pack();
>      }
>      catch(Exception ex) {
>        ex.printStackTrace();
>      }
>    }
> 
>    public LoggingDialog() {
>      this(null, "", false);
>    }
>    private void jbInit() throws Exception {
> 
>      panel1.setLayout(borderLayout1);
>      getContentPane().add(panel1);
>      panel1.add(chainsaw, BorderLayout.NORTH);
> 
>    }
> }
> 
> Unfortunatly it does not work. I get the Dialog but there are no logs 
> written to it.
> I tried doing things like
> 
> BasicConfigurator.configure(new 
> org.apache.log4j.chainsaw.ChainsawAppender());
> org.apache.log4j.Logger.getRootLogger().addAppender(new 
> org.apache.log4j.chainsaw.ChainsawAppender());
> 
> before and added a org.apache.log4j.netSocketAppender to my 
> log4j.properties nothing helped.
> 
> This all using log4j-1.3alpha.jar and log4j-chainsaw-1.3alpha.jar.
> 
> Has anybody here been able to use chainsaw within a custom application?
> How?
> Best regards,
> Carsten
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org