Are you
looking for an option o update the Log4J logger level dynamically for a web
application? If so, here is the solution for people like you to update the
logger which doesn’t require any log4j,xml
file configuration change or serve restart.
Here we had
developed a jsp page that will show the current loggerName, loggerlevel and the
list of logger levels lits it can take. Now, you can select the new log level
from selectbox to set the new logger on the fly.
Here is the
code sample. Wanna try?
<%@ page
import="org.apache.log4j.*"%>
<%@ taglib prefix="c"
uri="http://java.sun.com/jsp/jstl/core"%>
<%
Logger
logger = Logger.getRootLogger();
logger.setLevel(Level.toLevel(
request.getParameter("selectedLevel"),
Level.INFO));
%>
No comments:
Post a Comment