Hybris Runtime Development Tools: hybris Logging – hybrismart | SAP hybris under the hood

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). 

./hybrisLog

or (for non-wrap output)

./noWrap ./hybrisLog

2016-08-28_23h43_58

You 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 -a

There are thousands of classes in the output, so you can use the filters to narrow them:

./hybrisLog -a | grep "FlexibleSearch"

2016-08-28_23h52_48

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 -l

2016-08-28_23h55_34

Change 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:

multilog.png

© Rauf Aliev, August 2016

 

5 Responses

  1. André Roque Matheus

    André Roque Matheus

    Reply

    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.

  2. Ashwan Guni

    Ashwan Guni

    Reply

    15 December 2016 at 09:10

    Hi Rauf,

    Where can I find the logging tool you developed

Leave a Reply