In my application, I am running my code through PMD.It shows me this message:
- Avoid printStackTrace(); use a logger call instead.
What does that mean?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It means you should use logging framework like logback or log4j and instead of printing exceptions directly:
you should log them using this frameworks’ API:
Logging frameworks give you a lot of flexibility, e.g. you can choose whether you want to log to console or file – or maybe skip some messages if you find them no longer relevant in some environment.