14

I have a simple web app running on Tomcat 5.5 with log4j for logging. Occasionally I need to push the logging down to DEBUG but most of the time I'm happy with INFO.

I can change my config xml and restart the app but I would prefer to switch the log levels on the fly. Is there a standard technique for this?

1
  • consider exposing the logger via JMX? Commented Jul 29, 2009 at 16:00

2 Answers 2

6

Just use the programmatic API:

logger.setLevel(Level.DEBUG) 

in your program when you need more verbose logging output, and

logger.setLevel(Level.INFO) 

to make it less verbose again.

Sign up to request clarification or add additional context in comments.

1 Comment

If you're using weblogic they have a drop-in JSP that allows you to adjust all running loggers using this API.
5

I created a new java application module (jar) to do this in a web interface at runtime, and also have a page to view the log result. Configure the jar is very simple: must be placed in the /WEB-INF/lib folder, and add a mapping to the servlet in the /WEB-INF/web.xml file.

Project site: http://www.log4jwebtracker.com

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.