I ran into this problem myself, Sre, and happily, I found a solution that
works.

IF you are going to wrap log4j's wrapper Logger class with your own wrapper
class, in this case, your Log4j class, you need to make sure that your
wrapped class calls this form of Logger.log:

--- paste from log4j javadoc ----

public void log(String callerFQCN,
                Priority level,
                Object message,
                Throwable t)

This is the most generic printing method. It is intended to be invoked by
wrapper classes.
Parameters:
callerFQCN - The wrapper class' fully qualified class name.
level - The level of the logging request.
message - The message of the logging request.
t - The throwable of the logging request, may be null. 


-- end paste --

Make sure you pass your wrappers class name in the callerFQCN arg, and then
log4j will be smart enough to get the line and filename information to the
appender.

Hope this helps.

doug

  >  -----Original Message-----
  >  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
  >  Sent: Wednesday, October 29, 2003 10:29 AM
  >  To: [EMAIL PROTECTED]
  >  Subject: File name and Line number problem
  >  
  >  Hi,
  >  
  >  I am trying to implement log4j across the entire project, 
  >  there are about 1000 files in the project.
  >  
  >  What I have done is to have a utility class Log4j.java and 
  >  thru my startup program initialize all the default log4j 
  >  properties. (loggers,appender etc.) from the specified 
  >  property file All of the other programs just invoke the 
  >  method com.abc.util.Log4j.log("some string") method.
  >  
  >  Everything works great up and all messages get trapped to 
  >  the specified appender except for this one issue.
  >  
  >  The file and line number I specify correspond to the 
  >  utility class and not the actual class that is printing 
  >  this message.
  >  when I use the conversion pattern (%F:%L)
  >  
  >  E.g. If there is this class - Example.class and at line#35 
  >  there is a statment com.abc.util.Log4j.log("Test message");
  >  
  >  The file name printed on the log file corresponds to the 
  >  Log4j.java and the line number corresponds to the log 
  >  method in that file.
  >  
  >  Best regards,
  >  Sre
  >  
  >  
  >  
  >  
  >  -----------------------------------------------------------
  >  ----------
  >  To unsubscribe, e-mail: [EMAIL PROTECTED]
  >  For additional commands, e-mail: [EMAIL PROTECTED]
  >  
  >  


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to