Issue
- How can I configure Log4j to use asynchronous logging in Liferay?
Environment
- DXP 7.2
- DXP 7.3
- DXP 7.4
- Quarterly Releases
Resolution
DXP 7.2 and DXP 7.3
NOTE: The following resolution requires customization and should only be implemented at the discretion of your team. Liferay Support will not be able to assist with designing or implementing customizations.
- In 7.2 and 7.3, you can configure asynchronous logging by editing the log4j configuration file.
- Create a
portal-log4j-ext.xml
file following the instructions at Adjusting Log Levels to persist after portal restart - Then modify the file to define a new appender of the class
org.apache.log4j.AsyncAppender
, and reference that appender from the root appender:
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender" />
...
<root>
...
<appender-ref ref="ASYNC" />
...
</root>
- For a more detailed example, see the attached DXP 7.2
portal-log4j-ext.xml
.
DXP 7.4 and Quarterly Releases
NOTE: Liferay Support does not recommend or endorse specific third-party products over others. The information provided about products not created by Liferay is for reference purposes only, and any implementation of these principles will be at your team's discretion.
- In 7.4 and above, we migrated to version 2.x of log4j.
- In log4j 2.x, you can deploy a third-party disruptor.jar to gain access to an AsyncLogger that you can configure to make all loggers asynchronous with a system property.
- See Log4J's 'Asynchronous Loggers for Low-Latency Logging' for detailed instructions.
Additional Information
- See Adjusting Log Levels to persist after portal restart for information on editing the log4j configuration file.
- See Log4j's documentation on the AsyncAppender for more information on how to use the appender.
- See Log4j's 'Asynchronous Loggers for Low-Latency Logging' for information on how to configure Asynchronous Loggers.
Contenido exclusivo para suscriptores.
Una Suscripción Enterprise de Liferay proporciona acceso a más de 1.500 artículos que incluyen las mejores practicas, diagnóstico de problemas y otras soluciones útiles. Inicia sesión para tener un acceso completo.
Inicia sesión