Bundle: logcommands
Version 5.0.0

Logcommands

Log service console commands to view log entries and configure the log-service.

Description

The logcommands bundle publishes two command groups: The log command group consists of a single command show that interacts directly with the log service to get and display available log entries. The logconfig command group offers commands for configuring a log service implementation. E.g., number of log entries to keep in memory, if entries should be printed to standard out or not, if entries are to be saved to a file or not.

Log - Log commands

The log command group consists of a single command, show, that interacts directly with the log-reader service to get and display available log entries.

The group contains the following command:

This command group works with any OSGi compliant log-service implementation.

show

The show command is used to show selected log entries that are available from the log service, i.e., held in memory.

Entries will be ordered with the most recent entry first. If no bundle argument is supplied, log entries from all bundles are considered.

  show [-help] [-f] [-h #hours#] [-l #level#] [-n #count#] [-s] [<bundle>] ...

Parameters:

-help
Display command help text.
-f
Show only entries for events from the framework.
-h #hours#
Show only entries since #hours# back. Note that 'hours' is a float so that smaller time than one hour is possible.
-l #level#
Show only entries with minimum #level# of one of error, warning, info or debug.
-n #count#
Show at most #count# entries, that is, the #count# most recent entries that fulfills the selection criteria.
-s
Show the stack trace for exceptions.
<bundle>
Name or id of bundle. The value "*" may be used to list entries from all bundles except the framework itself.

Examples

Show log error entries.

  log> show -l error
  07/06 15:16:41 ERROR #19, messenger -
  Failed to load configuration / java.io.FileNotFoundException:
  /demo/gatespace/bin/host.conf
  (No such file or directory)
  07/06 15:16:41 ERROR FRAMEWORK -
  FrameworkError: org.osgi.framework.BundleException:
  Bundle.start: BundleActivator start failed
  07/06 15:16:41 ERROR #18, authentication -
  Failed to read KeyStore / java.net.MalformedURLException:
  null: java.lang.NullPointerException: 

Logconfig - Configuration commands for the log

The logconfig command group offers commands for configuring a log service implementation.

This command group only works with log service implementations that publishes a org.knopflerfish.service.log.LogConfig.

The group contains the following commands:

memory

The memory command is used to control the number of log entries that are held in memory.

If the command is given without any parameters the current maximum number of log entries is shown.

Show and set the number of log entries in memory.

  memory [-help] [<int>]
Parameters:
-help
Display command help text.
<int>
The maximum number of log entries held in memory.

setlevel

The setlevel command is used to control what log entries are actually written to the log. There is one default log level and in addition each bundle can have its own setting. A log level may also be set giving a bundle short name in which case all bundles with this name will be logged at the given level. The default level is used for bundles without log levels of their own.

Entries with a severity level higher or the same as the current default level will be logged. For example, with the default level set to warning, entries with level warning or error will be logged.

The severity order of the levels is:

Set log level.

  setlevel [-help] <level> [<bundle>] ...
Parameters:
-help
Display command help text.
<level>
The new log level. One of error, warning, info, debug or default.
<bundle>
URL, short name, or id of bundle. A URL or bundle id must be used if wanting to set the log level of one specific bundle. When supplying a bundle short name all bundles with this name will be logged at the given level. If no bundle is given the default log level is set.

showlevel

The showlevel command lists the default log level and the levels for the specified bundles, or for all bundles if no bundle is specified (only bundles with a level different from the default level are listed).

The output has columns for bundle id, log level and bundle name. A "*" in the id column indicates the default level, and a "-" in the same column indicates that the log level was set with a bundle short name or that the bundle is not yet installed. The bundle name column may contain a bundle short name or if the log level of a bundle not yet installed is set the bundle location will be displayed instead.

Show current log levels.

  showlevel [-help] [<bundle>] ...
Parameters:
-help
Display command help text.
<bundle>
URL, bundle short name or id. Shows level for a specific bundle if a bundle id or location is given. When supplying a bundle short name the log level for all bundles with this name will be displayed.
Example: Default and bundle log levels

  logconfig> setlevel warning console
  logconfig> showlevel
  *  debug    (default)
  2  Warning  console
  -  Warning  console   (default)

out

Enables printout of all log entries on standard out. The entries are written to the log as well.

The out command is disabled if no valid configuration has been received, that is, the Configuration Management(CM) component has not generated a configuration or the CM component is not available. See [1] for further description of the configuration procedure.

If the command is given without parameters the present setting is shown.

  out [-help] [-on | -off]
Parameters:
-help
Display command help text.
-on
Turns on writing of log entries to standard out.
-off
Turns off writing of log entries to standard out.

file

This command controls the writing of log entries to file, the size of log files, how many generations of log files to keep and whether each log entry should be flushed to file.

The file command is disabled if no valid configuration has been received, that is, the Configuration Management(CM) component has not generated a configuration or the CM component is not available. See [1] for further description of the configuration procedure.

If the command is given without parameters the present setting is shown.

Note that a change in log file size does not take effect until the present log file has been filled and a new is started.

Configures the writing of log entries to file.

  file [-help] [-on | -off [-size #size#] [-gen #gen#] [-flush | -noflush] 
Parameters:
-help
Display command help text.
-on
Turns on writing of log entries to file.
-off
Turns off writing of log entries to file. 1
-size #size#
Sets the maximum size (in characters) of a log file.
-gen #gen#
Sets the number of log file generations that are kept.
-flush
Turns on log file flushing after each log entry.
-noflush
Turns off log file flushing after each log entry.

timestamp

The timestamp command shows or sets the formatting pattern for the time-stamp in a log entry. This formatting pattern applies to log entries written to the file log and to the console when out has been activated. It does not apply to output of the log-command.

When called without an argument it prints the current formatting pattern.

  timestamp [-help] [<pattern>]
Parameters:
-help
Display command help text.
<pattern>
The new time-stamp formatting pattern. The pattern follows the rules for time formatting patterns defined by the java.text.SimpleDateFormat-class. The default pattern is "yyyyMMdd HH:mm:ss".
Example: Extend the time-stamp format to include milliseconds, then call without argument to check that the new pattern was applied.

  logconfig> timestamp 'yyyyMMdd HH:mm:ss.SSS'
  logconfig> timestamp
    time stamp pattern: 'yyyyMMdd HH:mm:ss.SSS'.

Examples

Turn on writing to standard out

      logconfig> out -on
    

Turn on flushing of buffers after each log entry.

      logconfig> file -flush
    

See Also

Log

Bundle Jar docs

logcommands-5.0.0

Exported Packages

No exported packages.