Adjusting Module Logging

Liferay DXP uses Log4j logging services. Here are the ways to configure logging for module classes and class hierarchies.

  • Log Levels in Liferay DXP’s UI
  • Configure Log4j for multiple modules in a [anyModule]/src/main/resources/META-INF/module-log4j.xml file.
  • Configure Log4j for a specific module in a [Liferay Home]/osgi/log4j/[symbolicNameOfBundle]-log4j-ext.xml file.
  • Configure Log4j for an OSGi fragment host module in a /META-INF/module-log4j-ext.xml file

Here’s an example Log4j XML configuration:

<?xml version="1.0"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="">
    <category name="">
        <priority value="DEBUG" />

Use category elements to specify each class or class hierarchy to log messages for. Set the name attribute to that class name or root package. The example category sets logging for the class hierarchy starting at package Log messages at or above the DEBUG log level are printed for classes in and classes in packages starting with

Set each category’s priority element to the log level (priority) you want.

  • ALL
  • INFO
  • WARN
  • OFF

The log messages are printed to Liferay log files in [Liferay_Home]/logs.

You can see examples of module logging in several Liferay sample projects. For example, the action-command-portlet, document-action, and service-builder/jdbc samples (among others) leverage module logging.

That’s it for module log configuration. You’re all set to print the information you want.

Implementing Logging

« Connecting to JNDI Data SourcesImplementing Logging »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 1