Hybris Runtime Development Tools: hybris Logging

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

 

5 comments

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

    Liked by 1 person

    1. Unfortunately, I didn’t face to this task before

      Like

  2. Ashwan Guni · · Reply

    Hi Rauf,

    Where can I find the logging tool you developed

    Like

    1. Send a request to me please, Rauf_aliev@epam.com

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: