Check out example codes for "log4j print stacktrace". It will help you in understanding the concepts better.

Code Example 1

try {
   ...
} catch (Exception e) {
    log.error( "failed!", e );
}

Learn ReactJs, React Native from akashmittal.com