File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes Log4j, How to create a logger? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log4j, How to create a logger?" Watch "Log4j, How to create a logger?" New topic

Log4j, How to create a logger?

M Jay
Ranch Hand

Joined: Sep 21, 2004
Posts: 66

I am trying to use log4j to log activity within my web application, I've had a look at the tutorial at Apache's website but was not much helpful.

Basically I want to create 3 types of loggers:

1- Debug Logger (to log debug related stuff)
2- Error Logger (to log errors)
3- Performance Logger (to log performance related stuff)

How do I go about this?
Do I subclass the Logger class for each one of those?
And then how do I specify to which file each one logs?

If anyone can help me or direct me to a useful resource I would be grateful.


SCJP J2SE 1.4<br />SCBCD J2EE 1.3
M Jay
Ranch Hand

Joined: Sep 21, 2004
Posts: 66
How do I specify the log file's name to be a dynamic name, for example if it's a daily rolling logger than I want the name of the file to have the date?
Carol Enderlin
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
I thought the The complete log4j manual (in PDF format) was an excellent tutorial.
It's not free, but was written by log4j developer.

I didn't use the complete manual to get started with log4j, we just used the Short Introduction to log4j.

If those don't meet your needs, I'd suggest google to find some instructions that make more sense to you.
I agree. Here's the link:
subject: Log4j, How to create a logger?
jQuery in Action, 3rd edition