4.3. Logging system
Karaf provides a powerful logging system based on OPS4j Pax Logging.
In addition to being a standard OSGi Log service, it supports the following APIs:
- Apache Commons Logging
- SLF4J
- Apache Log4j
- Java Util Logging
Karaf also comes with a set of console commands that can be used to display, view and change the log levels.
Configuration
The configuration of the logging system uses a standard Log4j configuration file at the following location:
[karaf]/etc/org.ops4j.pax.logging.cfg
You can edit this file at runtime and any change will be reloaded and be effective immediately.
Commands
The log subshell comes with 3 commands:
log:display
: display the last log entrieslog:display-exception
: display the last exception from the loglog:get
: show the log levelslog:set
: set the log levels
For example, if you want to debug something, you might want to run the following commands:
> log:set DEBUG ... do something ... > log:display
Note that the log levels set using the log:set
commands are not persistent and will be lost upon restart.
To configure those in a persistent way, you should edit the configuration file mentioned above.
#top