views:

230

answers:

1

Does log4J still gather the class, method and line numbers by generating exceptions and inspecting the stack trace?

Or has Java been optimized since Sun included their own logging framework.

If not, why has there not been any optimizations made since. What is the main challenges in obtaining class, method and line numbers quickly and efficiently?

Although I hate annotations and try to avoid them, has log4J not made use of this, such as:

@log4j-class MyClass

@log4j-method currentMethodOne

At least this would avoid some companies bad habit of repeatedly writing/copying the method name as the first part of their logging message (which is seriously annoying).

Thanks,

Jeach!

A: 

According to this page, last update of Log4j was in August, 2007. I never heard of annotation support, nor do I understand what purpose would it have.

As for the method name is the logging message, you can always edit log4j.properties or log4j.xml configuration file, and change the layout pattern of the desired appender. The pattern will apply to your own classes and any 3rd party libraries using log4j - that is one of the purposes of using a logger.

Just omit the M in the layout pattern and Log4j won't be gathering caller information.

javashlook