Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7022201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:33:01+00:00 2026-05-27T23:33:01+00:00

I am going to deploy our Web Application under Production server. Is including printStackTrace

  • 0

I am going to deploy our Web Application under Production server.
Is including printStackTrace under catch block in production environment acceptable? (becuase the logs under catch block doesn’t help to know the exact cause for the error)
So please tell me if is it aceptable to have printStackTrace under catch block?

For instance, I purposefully put an invalid port number and printStackTrace() gives me this information.

printStackTrace() :

java.lang.IllegalArgumentException: port out of range:80800
        at java.net.InetSocketAddress.<init>(InetSocketAddress.java:118)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:395)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:530)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:234)
        at sun.net.www.http.HttpClient.New(HttpClient.java:307)
        at sun.net.www.http.HttpClient.New(HttpClient.java:324)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1014)
        at com.tata.util.XmlClient.execute(HttpXmlClient.java:83)

Log style :

And where as the log gives this (I am using Apache commons logging mechanism for logging)

 Log.write("**EXCEPTION INSIDE execute " + e, Log.INFO);

06/Jan/2012 16:25:55   - main:http-8080-2 <> <60990020>**EXCEPTION INSIDE execute  java.lang.IllegalArgumentException: port out of range:80800

So please tell me if is it acceptable to have printStackTrace under catch block?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:33:02+00:00Added an answer on May 27, 2026 at 11:33 pm

    The log will show the stacktrace as well, but you’re not using it correctlly. Try:

    log.error(Object message, Throwable t);
    

    When you do Log.write("**EXCEPTION INSIDE execute " + e, Log.INFO); the plus sign used as String concatenator will in fact call the toString() method on the e object, and append that to the "**EXCEPTION INSIDE execute " String, never getting a change to get to the exception object or it’s stack trace.

    http://commons.apache.org/logging/guide.html#Logging a Message

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I'm going to deploy to an environment with my application running with
To deploy ASP.Net web application in a 64 bit IIS 7 web server, Should
We're using Warbler to deploy our application to JBoss. The server seems to start
I am going to deploy my first MVC web application to the internet. As
I'm going to build an installer to deploy my application which is a Windows
I will shortly be going live with a new .net web application. It will
My company wants to start mobile web application development, as an addition to our
We are new to Azure and are going to deploy our first app in
I'm going to deploy an ASP.NET MVC project on IIS (6.0 & 7.5) but
I'm going to deploy my Java game to show it to my friends and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.