Log4j Debug and Info

A

akhileshkokardekar

Hi All,

I have started using log4j recently. I have tried to put both INFO and
DEBUG on console and in a file but it throws an exception

log4j:ERROR Attempted to append to closed appender named [Console].
log4j:ERROR Attempted to append to closed appender named [RollingFile].

So can i conclude that INFO and DEBUG information cannot be generated
simultaneously. If i am using only INFO or only DEBUG it is working
fine.

Waiting for your response guys...


Regards,
Akhilesh
 
L

Lew

Hi All,

I have started using log4j recently. I have tried to put both INFO and
DEBUG on console and in a file but it throws an exception

log4j:ERROR Attempted to append to closed appender named [Console].
log4j:ERROR Attempted to append to closed appender named [RollingFile].

So can i conclude that INFO and DEBUG information cannot be generated
simultaneously. If i am using only INFO or only DEBUG it is working
fine.

I don't know what you mean by "simultaneously". Are you suggesting some sort
of ORing of levels, as logger.log( INFO + DEBUG, msg )? That would be
meaningless, since DEBUG < INFO. If a DEBUG message would log, so would an
INFO message.

Are you simply saying you want to issue log statements at different levels
from the same code, as

....
logger.log( INFO, msgA );
logger.log( DEBUG, msgB );
?

That is not only possible in log4j, it is a favoured idiom.

However, if your appender is closed you cannot log anything.

<http://logging.apache.org/log4j/docs/manual.html>

- Lew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top