How to add you custom class in HAC logging list?

Scenario

Hybris use log4j2 logger. We can change the log level for preconfigured classes from the HAC > Platform > Loggin (like root, org.springframework etc.). But what if we want to configure logger for our custom class.

Solution

  • Add logger statement in your java class
  • add log4j2 configuration for your custom Java class
  • Restart the Hybris server

MyService.Java
private static final Logger LOG = Logger.getLogger(MyService.class);

LOG.debug("I am debug log");
local.properties
\#log4j2 configuration

log4j2.rootLogger.level = warn

log4j2.logger.myService.name = com.extended.service.impl.MyService
log4j2.logger.myService.level = warn
log4j2.logger.myService.appenderRef.stdout.ref = STDOUT

log4j2.logger.customService.name = com.extended.service.impl.CustomService
log4j2.logger.customService.level = warn
log4j2.logger.customService.appenderRef.stdout.ref = STDOUT

Do you know this also can be done without restarting Hybris server?
Author Image

Ankitkumar Patel

Sr. SAP Hybris consultant, having 15+ years experience in SAP Commerce Cloud (Hybris), SAP Spartacus. Extensive experience in SAP Hybris development, third-party integrations, project architecture and design... Read more

Comments

Popular posts from this blog

Hybris flexible search query examples

How to remove or update all data records in Hybris?

How to Install temporary Hybris license?