You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
8Because jqno's answer actually uses the Throwable.getStackTrace() method that you specified in your question, whereas Brian doesn't. He uses Throwable.printStackTrace() instead.Stijn de Witt– Stijn de Witt2012-01-31 18:45:09 +00:00Commented Jan 31, 2012 at 18:45
-
10Just about every Java project should include Apache commons-lang. It includes many convenience methods implementing extremely common development needs.Russell Silva– Russell Silva2013-08-15 21:32:45 +00:00Commented Aug 15, 2013 at 21:32
-
20@StijndeWitt Those three lines of code almost certainly need factoring out of the place you've called them. Since you don't know where to put them, they'll go in your utility toolbox with all the other useful snippets. Bingo! you've just reinvented guava / commons-lang / whatever... only not so well. Import a sensible utilities library instead, and save reinventing the wheel. The true sign of a novice is thinking you can do a better job than the library writers.Andrew Spencer– Andrew Spencer2013-10-22 08:12:48 +00:00Commented Oct 22, 2013 at 8:12
-
91. Guava has - Throwables.getStackTraceAsString(e) 2. Apache Commons Lang - ExceptionUtils.getFullStackTrace 3. Write our own custom methodsuser2323036– user23230362014-03-10 10:52:44 +00:00Commented Mar 10, 2014 at 10:52
-
16@AndrewSpencer I don't understand why you guys try so hard to bash StijndeWitt for wanting to achieve this with some small snippet. There is really not much danger in writing a tiny utility method (I don't see it as "SHEER ARROGANCE oh nooooo!! he thinks he's better than Apache!!"). There are tons of projects especially in non-Java JVM languages that really don't want to include Guava or Commons Lang just to log a stacktrace. I write Scala & Clojure libraries and certainly will not be making Apache Commons Lang a transitive dependency just for one method.jm0– jm02016-03-02 16:30:38 +00:00Commented Mar 2, 2016 at 16:30
|
Show 7 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. python-3.x), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-java