[See also the newer article with the Groovy Script for the same purpose]
Introduction
Starting with version 6.0, SAP changed the architecture of the hybris logging subsystem. Hybris uses the Apache Log4j 2 logging framework, which is configured differently in hybris. Any changes in the logging configuration are applied only if the server is restarted.
Starting with hybris 6.0, the architecture of the Hybris Administrative Console (HAC) was changed. As a consequence, the logging configuration capabilities were restricted. For example, in previous versions, you were able to change the 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 only the root loggers, numbering 14 items.
For example, according to the documentation, if you want to turn logging on for de.hybris.platform.jalo.flexiblesearch.FlexibleSearch with 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 = STDOUTChallenge
Logging is a very efficient tool for troubleshooting, so I was really frustrated to wait every single time I needed to add or change the logging settings. It is very annoying.
So I took up the challenge of creating a logging tool that simplifies common log operations and management.
hybrisLog
Usage examples
Display the hybris log, like tail -f.
./hybrisLogOr, for non-wrapped output:
./noWrap ./hybrisLog
You can use filters (grep, egrep) or data processors (awk, perl) to make the log more focused on the problem you are dealing with:
./hybrisLog | grep "[FlexibleSearch]" | grep -i "{ContentPage}"Show all classes that are loggable and registered in Apache Log4j.
./hybrisLog -aThere are thousands of classes in the output, so you can use filters to narrow them down:
./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 custom configurations will change too.
./hybris -l
Change the log level for the specified class or package: a fully 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 DEBUGPlease note that the last command performs a bulk change for all classes in the de.hybris.platform.solrfacetsearch.indexer package:

© Rauf Aliev, August 2016