Hi Brian, >From the javadoc for Thread getStackTrace():
"Some virtual machines may, under some circumstances, omit one or more stack frames from the stack trace. In the extreme case, a virtual machine that has no stack trace information concerning this thread is permitted to return a zero-length array from this method.". Hard to see a workaround for that, if it can/does happen. Cheers Brett On Wed, Jan 28, 2009 at 3:43 PM, Brian Hawkins <brianh...@gmail.com> wrote: > You missed what I'm trying to do. I'm defining a static logger such as > this: > > public class MyClass { > private static final Logger myLogger = Logger.getLogger(MyClass.class); > } > > But what I would like to do is this > > public class MyClass { > private static final Logger myLogger = Logger.getLogger(); > } > > Notice the getLogger call has not parameter now. Inside of > Logger.getLogger() it does the stack trace to find the class that it is > being declared in. > > I'm working on a Struts2 application with a lot of actions. The tendency > is > when creating a new action to find one similar and cut and past it to the > new one. The parameter to the getLogger call is easily missed when > renaming > the class name. But with my change the getLogger call automagically > figures > out the class in which it is declared. This creates cleaner code that is > easier to maintain. > > Brian > > > On Tue, Jan 27, 2009 at 7:53 PM, Craig P. Motlin <mot...@gmail.com> wrote: > > > This is a non-issue. If you need to log an object's type, call > > getClass().getName() and log it as a normal message. Stick to one > > private static logger in each class. The logger name will represent > > where the logging statement occurred, not the run time type of the > > logging object. > > > > >