Logs
The OSGi Log Service Extender enables bundles to provide OSGi logging configuration using embedded properties files META-INF/osgi-logging.properties
or META-INF/osgi-logging-ext.properties
. Each line in the files is a key-value pair with a logger name and the logging level:
com.foo=DEBUG
com.foo.bar=ERROR
Liferay supports four logging levels:
- ERROR - Information about an error situation.
- WARN - Information about a failure or unwanted situation that is not blocking.
- INFO - Information about normal operation.
- DEBUG - Detailed output for debugging operations.
Gogo Shell Logging Commands
Gogo shell commands are provided to interact with log levels in real time. The available commands are in the logging
command scope (following the syntax <scope>:<command>
).
The scope and colon (<scope>:
) can usually be omitted when executing commands and are only required to disambiguate conflicting command names.
There are two available commands:
-
logging:levels <context>
lists the levels associated with a given logger context. Replace<context>
with the logger context name. It must use one of the following syntaxes:<Bundle-SymbolicName>
<Bundle-SymbolicName>|<Bundle-Version>
<Bundle-SymbolicName>|<Bundle-Version>|<location>
null
- returns the default logger context
For example, to list the levels in the context
com.liferay.oauth2.provider.service
:g! levels org.apache.felix.configadmin
-
logging:level <context> <name> <level>
sets the level of a named logger in a given logger context. Replace<context>
with the logger context name following the syntax specified above. Replace<name>
with the name of the logger. Replace<level>
with the desired level (ERROR
,WARN
,INFO
, orDEBUG
). The logger level is case insensitive.Here’s how to set the level of the named logger
com.liferay.oauth2.provider.service.persistence.impl
toDEBUG
in the contextcom.liferay.oauth2.provider.service
:g! level com.liferay.oauth2.provider.service com.liferay.oauth2.provider.service.persistence.impl debug
Mapping of Legacy OSGi Log Events
In the OSGi Log Service version 1.4, there are four additional logger names which map previously uncategorized legacy log events and allow control over them.
Events.Bundle
- logger name for Bundle EventsEvents.Service
- logger name for Service EventsEvents.Framework
- logger name for Framework EventsLogService
- logger name forLogService
events
Using these logger names, you can adjust the level of a bundle’s legacy LogService
events using the properties file or a Gogo shell command:
com.foo=DEBUG
com.foo.bar=ERROR
LogService=DEBUG
g! level org.apache.felix.configadmin LogService DEBUG