You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Feigin Yaron <Ya...@comverse.com> on 2007/01/14 10:50:51 UTC
Receive the File & line number
Hi all,
Is there an optimized way via the log4j functions to receive the line we
are printing from without printing all stack and manipulating it?
In C/C++ there is a __LINE__ macro that do the job...
Is there an equivalent in java for that?
Many thanks,
Yaron Feigin
Re: Receive the File & line number
Posted by Ryan Shelley <rs...@csun.edu>.
Can't you use %L in the configuration file for the pattern?
ConversionPattern=(%F:%L)
Generates file name and line number separated by a colon...
MyFile.java:1
http://logging.apache.org/log4j/docs/api/org/apache/log4j/
PatternLayout.html
It's not optimized, however. I don't believe there's a simple,
optimized, means of getting the line number from java (otherwise it
probably would be used by Log4J inherently).
On Jan 14, 2007, at 1:50 AM, Feigin Yaron wrote:
> Hi all,
> Is there an optimized way via the log4j functions to receive the
> line we
> are printing from without printing all stack and manipulating it?
> In C/C++ there is a __LINE__ macro that do the job...
> Is there an equivalent in java for that?
> Many thanks,
> Yaron Feigin
>