In Java, exception handling can be done in multiple ways. Let's differentiate exception handling using Logging framework as log4j
or sl4j
, where both of these could either redirect the logs to a file in addition to handle the exception.
If, instead of Logger framework, we use exception class method printStackTrace()
to handle the exception and to get the exception call stack by redirecting it to a file rather than to standard error output/console, now, following are the questions:
- Would the later implementation handle the exception at all OR will simply print the exception to file?
- On what grounds does implementing Logger framework is prefered over
printStacktrace()
in Production environment?
Thanks in advance!