Changing log level at runtime

J

Juergen Weber

You know the situation: logging output is useless .. until you need it.

Is there a way to configure log4j in a web application or an EJB with
log level ERROR and have it change to DEBUG whenever an error happens?

The only thing I can imagine is having a special servlet that you have
to call with the browser to have it trigger a log level change for the
whole web application.

Are there better ways? Maybe with the jdk built-in logger?

Or with log4j JMX? But I could not find any docs or examples.

Thx,
Juergen
 
R

Ryan Stewart

Juergen Weber said:
You know the situation: logging output is useless .. until you need it.

Is there a way to configure log4j in a web application or an EJB with log
level ERROR and have it change to DEBUG whenever an error happens?

The only thing I can imagine is having a special servlet that you have to
call with the browser to have it trigger a log level change for the whole
web application.

Are there better ways? Maybe with the jdk built-in logger?

Or with log4j JMX? But I could not find any docs or examples.
Do what? Things that should be logged when an error occurs should be logged
at the ERROR level. If you find yourself receiving insufficient information,
either rethink your logging or create another logger that logs at a lower
level to a different location, like a RollingFileAppender with a small size
and just one or two backups if you're worried about eating up a lot of
space.
 

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

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top