Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

log4j appender question

807597Sep 1 2005 — edited Jul 15 2008
I need some log4j help. Hope anyone can help me.

Question 1:
I need to log information to 4 different files. As far as I can tell from the log4j docs, I will then need to create 4 different appenders in the log4j.properties file. How can I do that?

Looking at examples, it looks like I will need to add 4 new sections similar to this one. Is that correct?
# Logfile 1
log4j.appender.log1=org.apache.log4j.RollingFileAppender
log4j.appender.log1.File=C:/Sun/logs/logme1.log


Question 2:
After that is done, how can I actually write to the files? When logging I was thinking just using: logger.info("log something").

How can I specify which file that will log to? Is that even the correct way to log?

Hope someone can help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 12 2008
Added on Sep 1 2005
13 comments
973 views