Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Scout/HowTo/4.0/Make use of the additional Scout logging features"

< Scout‎ | HowTo‎ | 4.0
(Created page with "{{ScoutPage|cat=HowTo 4.0}} The snipped below demonstrates you how to register keystrokes in Scout desktop to make use of the additional logging functionality:<br> With the ke...")
 
(Replaced content with "The Scout documentation has been moved to https://eclipsescout.github.io/.")
 
Line 1: Line 1:
{{ScoutPage|cat=HowTo 4.0}}
+
The Scout documentation has been moved to https://eclipsescout.github.io/.
The snipped below demonstrates you how to register keystrokes in Scout desktop to make use of the additional logging functionality:<br>
+
With the keystrokes 'CTRL-Shift-1' to 'CTRL-Shift-4', the log level can be changed at runtime. Also, recording of log messages is turned on if not the case yet.
+
To cancel recording and set the configuration to its origin state, 'CTRL-Shift-0' can be pressed.
+
<source lang="java">
+
public class Desktop extends AbstractDesktop {
+
 
+
/**
+
  * Instruct {@link ScoutLogManager} to load its origin logging configuration and turn off recording of log messages.
+
  * If recording was active, a file is displayed to the user containing all log messages since recording was started.
+
  */
+
  @Order(10)
+
  public class LogLevelDefaultKeyStroke extends AbstractKeyStroke {
+
 
+
    @Override
+
    protected String getConfiguredKeyStroke() {
+
      return "ctrl-shift-0";
+
    }
+
 
+
    @Override
+
    protected void execAction() throws ProcessingException {
+
      ScoutLogManager.setGlobalLogLevel(null);
+
 
+
      File file = ScoutLogManager.stopRecording();
+
      if (file != null) {
+
        Desktop.this.setStatusText("LOG level is set back to default and recording of log messages turned off");
+
        SERVICES.getService(IShellService.class).shellOpen(file.getAbsolutePath());
+
      }
+
      else {
+
        Desktop.this.setStatusText("LOG level is set back to normal");
+
      }
+
    }
+
  }
+
 
+
  /**
+
  * Instruct {@link ScoutLogManager} to only log messages of the severity ERROR and worse.
+
  * Also, turn on recording of log messages if not done yet.
+
  */
+
  @Order(20)
+
  public class LogLevelErrorKeyStroke extends AbstractKeyStroke {
+
 
+
    @Override
+
    protected String getConfiguredKeyStroke() {
+
      return "ctrl-shift-1";
+
    }
+
 
+
    @Override
+
    protected void execAction() throws ProcessingException {
+
      ScoutLogManager.setGlobalLogLevel(IScoutLogger.LEVEL_ERROR);
+
      if (ScoutLogManager.startRecording()) {
+
        Desktop.this.setStatusText("LOG level is set to ERROR and recording of log messages turned on");
+
      }
+
      else {
+
        Desktop.this.setStatusText("LOG level is set to ERROR");
+
      }
+
    }
+
  }
+
 
+
  /**
+
  * Instruct {@link ScoutLogManager} to only log messages of the severity WARNING and worse.
+
  * Also, turn on recording of log messages if not done yet.
+
  */
+
  @Order(30)
+
  public class LogLevelWarningKeyStroke extends AbstractKeyStroke {
+
 
+
    @Override
+
    protected String getConfiguredKeyStroke() {
+
      return "ctrl-shift-2";
+
    }
+
 
+
    @Override
+
    protected void execAction() throws ProcessingException {
+
      ScoutLogManager.setGlobalLogLevel(IScoutLogger.LEVEL_WARN);
+
      if (ScoutLogManager.startRecording()) {
+
        Desktop.this.setStatusText("LOG level is set to WARNING and recording of log messages turned on");
+
      }
+
      else {
+
        Desktop.this.setStatusText("LOG level is set to WARNING");
+
      }
+
    }
+
  }
+
 
+
  /**
+
  * Instruct {@link ScoutLogManager} to only log messages of the severity INFO and worse.
+
  * Also, turn on recording of log messages if not done yet.
+
  */
+
  @Order(40)
+
  public class LogLevelInfoKeyStroke extends AbstractKeyStroke {
+
 
+
    @Override
+
    protected String getConfiguredKeyStroke() {
+
      return "ctrl-shift-3";
+
    }
+
 
+
    @Override
+
    protected void execAction() throws ProcessingException {
+
      ScoutLogManager.setGlobalLogLevel(IScoutLogger.LEVEL_INFO);
+
      if (ScoutLogManager.startRecording()) {
+
        Desktop.this.setStatusText("LOG level is set to INFO and recording of log messages turned on");
+
      }
+
      else {
+
        Desktop.this.setStatusText("LOG level is set to INFO");
+
      }
+
    }
+
  }
+
 
+
  /**
+
  * Instruct {@link ScoutLogManager} to only log messages of the severity DEBUG and worse.
+
  * Also, turn on recording of log messages if not done yet.
+
  */
+
  @Order(50)
+
  public class DebugLogLevelKeyStroke extends AbstractKeyStroke {
+
 
+
    @Override
+
    protected String getConfiguredKeyStroke() {
+
      return "ctrl-shift-4";
+
    }
+
 
+
    @Override
+
    protected void execAction() throws ProcessingException {
+
      ScoutLogManager.setGlobalLogLevel(IScoutLogger.LEVEL_DEBUG);
+
      if (ScoutLogManager.startRecording()) {
+
        Desktop.this.setStatusText("LOG level is set to DEBUG and recording of log messages turned on");
+
      }
+
      else {
+
        Desktop.this.setStatusText("LOG level is set to DEBUG");
+
      }
+
    }
+
  }
+
}
+
</source>
+
 
+
== See Also ==
+
*[[{{BASEPAGENAME}}/Create_a_CustomLogManager_for_log4j|Create a CustomLogManager for Log4J]]
+
*[[{{BASEPAGENAME}}/Setup_different_Log-Configuration_for_Production_and_Development|Setup different Log-Configuration for Production and Development]]
+

Latest revision as of 07:34, 18 March 2024

The Scout documentation has been moved to https://eclipsescout.github.io/.

Back to the top