• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

level inheritence of logger problem

-here is my log file config:
log4j.rootLogger=DEBUG, A2

log4j.vn.edu.hut=DEBUG, A2

#log4j.appender.A1=org.apache.log4j.ConsoleAppender
#log4j.appender.A1.layout=org.apache.log4j.PatternLayout
#log4j.appender.A1.layout.ConversionPattern=%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n

log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.File=C:/tomcat5/Tomcat 5.5/webapps/axis/log4j.log
log4j.appender.A2.Append=true
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%-5r %-5p [%t] %l - %m%n

im my web application i do some logging as follow:
package vn.edu.hut;
class myHandler{
static Logger log = Logger.getLogger(myHandler.class.getName());
 ....  
log.debug("Contruct myHandler");
log.error("init handler: classname"+ myHandler.class.getName());
....
}
- My problem is i wanna log all debug informations from vn.edu.hut package.
How can i do this ?
0
hoaivan
Asked:
hoaivan
  • 3
  • 3
  • 2
  • +1
1 Solution
 
dorothy2Commented:
The code snippet you provided does not show how you are reading in the properties. In my app I have a PropertyManager class which reads in the properties and passes them to the code which initially sets up the Logger. Then I call "PropertyConfigurator.configure(properties)", which creates the Logger according to the properties I have read in.

Good luck,

Dorothy
0
 
dorothy2Commented:
There is a lot of documentation for Log4J. Here is a URL with some documentations and PowerPoint presentations that might help you. I would look at Ceki Gulcu's work first. Ceki has been documenting Log4J for years, and has written a book on the subject.

http://logging.apache.org/log4j/docs/documentation.html
0
 
hoaivanAuthor Commented:
@Dorothy: the web container do them for me, it automatically read properties file and ...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dorothy2Commented:
OK.

Have you defined a class variable?

Mine is:

private static Logger CAT;

Then in the class constructor I have

CAT = Logger.getLogger(getClass().getName());
CAT.info("Logger working.");

After I've got Log4J wired up, I remove the second statement.
0
 
hoaivanAuthor Commented:
dont you understand my question dorothy2 ?
any way i solved my problem: use the following config
log4j.logger.vn.edu.hut=DEBUG, LOGFILE

thanks all for your helping me
0
 
aozarovCommented:
I think you need to replace
log4j.vn.edu.hut=DEBUG, A2
with
log4j.logger.vn.edu.hut=DEBUG, A2
0
 
hoaivanAuthor Commented:
ya, i did it
0
 
aozarovCommented:
Oops, sorry I didn't see that you solved it already :-)
0
 
GhostModCommented:
PAQed with points refunded (500)

GhostMod
Community Support Moderator
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now