Posts

How to change class log level in Hybris without restarting server?

Image
Scenario Sometimes to debug the production issue, we want to enable log level for certain classes which were not configured in local.properties and we hope we could do it without restarting the Hybris server. Solution If your hybris version > v6 you can easily do this by navigating hac/platform/log4j . Here you can add your full class package and the log level you want.  In the older hybris version, you can do the same using the groovy script. Go to HAC > Console > Scripting language Past the below groovy script change your full class in setLogger method setLogger("de.hybris.platform.jalo.flexiblesearch.FlexibleSearch", "DEBUG"); execute the script import org.apache.logging.log4j.*; import org.apache.logging.log4j.core.config.*; import de.hybris.platform.util.logging.log4j2.HybrisLoggerContext; //Example setLogger("de.hybris.platform.jalo.flexiblesearch.FlexibleSearch", "DEBUG"); public String setLogger(String logCla

How to block certain URLs access for some user type in Hybris?

Scenario: How to block certain URLs access for some user type in Hybris? Solution: In general, we should maintain spring  Authorities/group  for such users so that it can be blocked from  spring-security . But in my case, I don't have that choice. There are already many userType which can be identified when the user logged in and stored it in session. Here I have to use same. So I have decided to use Spring AOP to serve my aspect around the point-cut(custom annotation). In this post, I am not going to cover AOP in detail. If you don't know anything about  Spring AOP . You should first  explore it  first. 1. Create Annotation AllowUsers and BlockUsers package com . hybris . storefront . annotations ; import java . lang . annotation . ElementType ; import java . lang . annotation . Retention ; import java . lang . annotation . RetentionPolicy ; import java . lang . annotation . Target ; @Retention ( RetentionPolicy . RUNTIME ) @Target ( { ElementType . M