• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

log4j question - package name & timestamp

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

I have just managed to completed 1 logger implementation for our j2ee project using log4j.

Though i can see all debug & other statements in the log file. Now the developers also want the timestamp at which the log was written in the log file since the same code is being tried out multiple times with modification.

One more question is how do i get the package name inside the log file. I have seen some log file where we get the full package structure & file name from which the log.debug () statement was issued.

How do i acheive this

Kindly respond

Rgrds
Hari
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More details would help in how to answer your questions. I will try to answer, but if you still have questions please provide more information.

How have you configured your log4j? Using a properties or xml file or programmatically? What kind of appender are you using?
How are you creating the Loggers?



Are you specifying the layout or using a default layout? The layout may be configured to include the date (%d) and name of the Logger (%c), see log4j manual and Java Documentation on PatternLayout.

If you're getting Loggers using Logger.getLogger(MyClass.class) or Logger.getLogger("com.foo.bar.MyClass"), the logger name is the fully qualified class name and that can be included using %c as mentioned above. If you're using some other naming convention for your loggers, then the documentation describes how to get the information, but it indicates the performance may be an issue.
[ April 13, 2005: Message edited by: Carol Enderlin ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic