Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Best practise to log in JSP file

Avatar

Level 6

Hi,

 

I would appreciate it if anyone could please point out to me any development article that would help me follow best practices in logging errors on a try {} catch () {} in JSP.

Regards

Clive Stewart

4 Replies

Avatar

Community Advisor

Hi Clive,

It seems like Adobe(view from outside) are moving away from jsp code with lot's of inline Java code.

Have you looked at more modern practices such as HTL's and Sling Models(look like more modern practices)?

Regards,

Peter

Avatar

Level 6

Hi Peter,

 

Unfortunately I am working on code written by other developers. They do not want to move to HTL. So when I look through their code all try {} catch() {} code suppress all errors. E.g
try {
Some Java code to read a resource
} catch (Exception e) {}

 

So I must make best of it as I cannot follow the best practice, which to me is use HTL (avoid JSP) and OSGI for business logic (i.e. do not have the java code for this in a jsp) , and where JSP is used keep the java simple. If its complex place it in OSGI. If it acceses JCr and othe Db resources, place it in OSGI.

 

But that is not up to me, so hence I am trying to think of what is the best way in AEM with JSP.
The simplest answer is to use the available implicit object, log as follows
=>  log.error("my error",e).