In the logging configuration that ships with the cassandra distribution 
(log4j-server.properties in 2.0, and logback.xml in 2.1), the rolling file 
appender is configured to print the file name and the line number of each 
logging event:

    log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) 
%m%n

Both the log4j 
<http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html>
 and logback documentation <http://logback.qos.ch/manual/layouts.html> warn 
that generating the filename/line information is not a cheap operation:

> Generating the file information is not particularly fast. Thus, its use 
> should be avoided unless execution speed is not an issue.

The implementation for both involves creating a new Throwable and then printing 
the stack trace for the throwable to find the file name or line number.

Is there a particular reason why the official distribution configures the 
logging like this, instead of using the logger name (%c)? 

Cassandra would seem like the perfect description of a place where execution 
speed is an issue.


Reply via email to