{"id":11,"date":"2008-08-25T11:47:00","date_gmt":"2008-08-25T11:47:00","guid":{"rendered":"http:\/\/www.andypalmer.com\/blog\/?p=11"},"modified":"2009-05-22T13:09:10","modified_gmt":"2009-05-22T13:09:10","slug":"well-how-did-i-get-here","status":"publish","type":"post","link":"https:\/\/andypalmer.com\/2008\/08\/well-how-did-i-get-here\/","title":{"rendered":"Well, how did I get here?"},"content":{"rendered":"
Once in a Lifetime – Talking Heads<\/i> A while ago, I was trying to replace a number of hard coded strings with an appropriate Enum. Unfortunately, the design of the code I was working on meant that it was difficult to find all the possible values for the strings. <\/p>\n <\/ul>\n The code I ended up with was something like this: Passing the And you may find yourself living in a shotgun shackAnd you may find yourself in another part of the worldAnd you may find yourself behind the wheel of a large automobileAnd you may find yourself in a beautiful house, with a beautiful wifeAnd you may ask yourself, “Well… how did I get here?” Once in […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[20,17,23],"_links":{"self":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts\/11"}],"collection":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/comments?post=11"}],"version-history":[{"count":1,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts\/11\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts\/11\/revisions\/121"}],"wp:attachment":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/media?parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/categories?post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/tags?post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
And you may find yourself living in a shotgun shack
And you may find yourself in another part of the world
And you may find yourself behind the wheel of a large automobile
And you may find yourself in a beautiful house, with a beautiful wife
And you may ask yourself, “Well… how did I get here?”<\/p>\n
<\/quote><\/p>\nLogging a Stack Trace in log4j<\/h3>\n
I decided that the behaviour that I wanted was:<\/p>\n<\/p>\n
public void doSomething(String theDestination) {
if(weKnowAbout(theDestination)) {
logger.debug(\"doSomething called with a known destination of \" + theDestination, new Throwable());
}
else {
logger.debug(\"doSomething called with unknown destination of \" + theDestination);
}
doWhatWeNeedToDoWith(theDestination);
}
<\/code><\/p>\nnew Throwable()<\/code> into log4j creates a stack trace in the log output. I’ve found a number of places that tell you how to do this (now that I know how to do it), but it took me quite a bit of searching when I was first looking.<\/p>\n","protected":false},"excerpt":{"rendered":"