-5

Why printStackTrace is not recommended to use in oracle ATG. If anyone knows please tell me.

Thanks in advance.

Ramya jois
  • 29
  • 5
  • 2
    Possible duplicate of [Avoid printStackTrace(); use a logger call instead](http://stackoverflow.com/questions/10477607/avoid-printstacktrace-use-a-logger-call-instead) – Alessandro Da Rugna Oct 26 '16 at 07:09

1 Answers1

0

Avoiding the use printStackTrace is not just limited to ATG but should be applied to JAVA development in general. The SonarQube validation rules explains it as follow:

Throwable.printStackTrace(...) prints a throwable and its stack trace to some stream. Loggers should be used instead to print throwables, as they have many advantages:

  • Users are able to easily retrieve the logs.
  • The format of log messages is uniform and allow users to browse the logs easily

With the availability of logError you are able to easily spool your error messages, not only to the standard dynamo.log and error.log but you can also see them in context of the rest of your application logs.

There is another SO question touching the same topic available here.

Community
  • 1
  • 1
radimpe
  • 3,197
  • 2
  • 27
  • 46
  • And importantly in an ATG context, you are able to configure if 'logError' is enabled at a component level. – bated Nov 03 '16 at 18:32