Hybris Runtime Development Tools: hybris Logging
[See also the newer article with the Groovy Script for the same purpose]
Introduction
Starting version 6.0 SAP changed the architecture of the hybris logging subsystem. Hybris uses the Apache Log4j 2 logging framework that is configured differently in hybris. Any changes in the logging configuration are applied only if the server is restarted. Starting hybris 6.0 the architecture of Hybris Administrative Console (HAC) was changed. As a consequence, the logging configuration capabilities were restricted. For example, in the previous versions, you were able to change a log level for all the beans defined in the system (thousands of items). For reasons that remain a mystery to me, in hybris 6.0/6.1 HAC shows the root loggers only, numbering 14 items. For example, according to the documentation, if you want to turn the logging on for de.hybris.platform.jalo.flexiblesearch.FlexibleSearch with the logLevel = WARN, you need to add the following fragment to the configuration file (this example is for the property configuration file):log4j2.logger.hmc.name = de.hybris.platform.jalo.flexiblesearch.Flex log4j2.logger.hmc.level = warn log4j2.logger.hmc.appenderRef.stdout.ref = STDOUT
Challenge
Logging is a very efficient tool for troubleshooting, so I was really embarrassed to wait every single time I need to add or change the logging settings. It is very annoying. So I had taken up the challenge of creating the logging tool which simplifies the common log operations and management.hybrisLog
Usage examples
Display hybris log (like tail -f)../hybrisLogor (for non-wrap output)
./noWrap ./hybrisLogYou can use the filters (grep, egrep) or data processors (awk, perl) to make the log more focused on the problem you deal with:
./hybrisLog | grep "[FlexibleSearch]" | grep -i "{ContentPage}"Show all classes that loggable (have registered in Apache Log4J).
./hybrisLog -aThere are thousands of classes in the output, so you can use the filters to narrow them:
./hybrisLog -a | grep "FlexibleSearch"Show all custom log configurations. If you change the default logging configuration (by using the utility or changing the local.property file), the list of the custom configuration will be changed too.
./hybris -lChange log level for the specified class/package (full qualified class name or the package name):
./hybris -c <classOrPackage> -ll <logLevel>Example: ./hybrisLog.sh -c de.hybris.platform.jalo.flexiblesearch.FlexibleSearch -ll INFO ./hybrisLog.sh -c de.hybris.platform.solrfacetsearch.indexer -ll DEBUG Please note, that the last command performs a bulk change, for all classes that are in the de.hybris.platform.solrfacetsearch.indexer package:
© Rauf Aliev, August 2016
André Roque Matheus
29 November 2016 at 11:39
Hi, do you know if it’s possible to upgrade hybris 5.7 log4j to version 2? It would help here with our logging needs, thanks.
Rauf Aliev
29 November 2016 at 12:30
Unfortunately, I didn’t face to this task before
André Roque Matheus
30 November 2016 at 07:44
Thanks!
Ashwan Guni
15 December 2016 at 09:10
Hi Rauf,
Where can I find the logging tool you developed
Rauf Aliev
15 December 2016 at 10:26
Send a request to me please, Rauf_aliev@epam.com