Looking at the list of HTL Global Objects in the documentation log is listed as a java-backed object backed by org.slf4j.Logger.
My question is, how can I use it?
I can't find any examples of it.
Thinking about it, this is a specific case of a more general question; How can I call methods and pass parameters to Java-backed objects?
I know it can be done when instantiating a Use-API object but that's not the pattern I'm after.
If it can't be done then it is hard to understand why the log and out objects are made available.
Solved! Go to Solution.
You can't specify arguments like ${log.info("hello")}
You can only make log statements via Java or JS code.
As stated in the docs - the log corresponds to the Java object. So you would use it in the front end like you would use it in the Java backend. ie
Java:
log.info("") ;
Front end :
"${log.info("")}
I have only used logging in back end - but this should work according to the docs. Also HTL spec here:
https://github.com/Adobe-Marketing-Cloud/htl-spec/blob/master/SPECIFICATION.md
Views
Replies
Total Likes
You can't specify arguments like ${log.info("hello")}
You can only make log statements via Java or JS code.
We will ensure that this fact is placed into the AEM docs.
Views
Replies
Total Likes
Adding to the Visser Statement
In Javascript which we call via sightly script add logs like
use(function() { log.error(“Log from Sightly JS Code");}
In Java Code
private final Logger log = LoggerFactory.getLogger(MyCustomClass.class);
private void mymethod(){
log.info("Event Path===>{}",evnt.getPath());
}
Views
Replies
Total Likes