Scott Deboy wrote:
> I added this in Dec 2004 to LogManager, but it was immediately reverted, even
> though it was a new method (not used by existing users).
>
> To implement it, I had to parse the stack trace of an exception (the same
> method used to discover location info), which was felt to be unsafe.
What about the approach suggested by Euxx?
public class ClassLocator extends SecurityManager {
public static Class getCallerClass() {
return new ClassLocator().getClassContext()[2];
}
}
>
> http://svn.apache.org/viewcvs.cgi/logging/log4j/trunk/src/java/org/apache/log4j/LogManager.java?rev=311088&view=markup
>
> Scott Deboy
> -----Original Message-----
> From: news on behalf of Daniel Serodio
> Sent: Wed 4/12/2006 7:47 AM
> To: [email protected]
> Subject: No-args Logger.getLogger()
>
> I've just came across an interesting post by Euxx[1] about a possible
> implementation of a no-args Logger.getLogger(), which "finds out" the
> calling class and returns a Logger for that class.
>
> Does anyone have experience with this approach? It seems like a valuable
> addition to log4j.
>
> Thanks,
> Daniel Serodio
>
> [1] http://www.jroller.com/page/eu?entry=looking_who_is_calling
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]