Commit af77674e authored by Tom Evans's avatar Tom Evans Committed by Dave Cridland

OF-460: Persist log.debug.enabled property

Fix settings for debug log so the admin UI setting is retained across
restarts. The system property "log.debug.enabled" may also be used to
manage this setting. If provided via openfire.xml, the property will be
migrated into the DB during startup.
parent 705864ad
......@@ -28,6 +28,7 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Openfire makes use of a logging facade (slf4j) to manage its log output. The
......@@ -46,17 +47,32 @@ import java.util.List;
public class Log {
private static final org.slf4j.Logger Logger = org.slf4j.LoggerFactory.getLogger(Log.class);
public static final String LOG_DEBUG_ENABLED = "log.debug.enabled";
// listen for changes to the log.debug.enabled property
static {
PropertyEventDispatcher.addListener(new PropertyEventListener() {
public void propertySet(String property, Map<String, Object> params) {
enableDebugLog(property, Boolean.parseBoolean(params.get("value").toString()));
}
public void propertyDeleted(String property, Map<String, Object> params) {
enableDebugLog(property, false);
}
// ignore these events
public void xmlPropertySet(String property, Map<String, Object> params) { }
public void xmlPropertyDeleted(String property, Map<String, Object> params) { }
private void enableDebugLog(String property, boolean enabled) {
if ((LOG_DEBUG_ENABLED).equals(property)) {
Log.setDebugEnabled(enabled);
}
}
});
}
// TODO deprecate these properties
// JiveGlobals.getXMLProperty("log.debug.format");
// JiveGlobals.getXMLProperty("log.info.format");
// JiveGlobals.getXMLProperty("log.warn.format");
// JiveGlobals.getXMLProperty("log.error.format");
// JiveGlobals.getXMLProperty("log.debug.size");
// JiveGlobals.getXMLProperty("log.info.size");
// JiveGlobals.getXMLProperty("log.warn.size");
// JiveGlobals.getXMLProperty("log.error.size");
// JiveGlobals.getXMLProperty("log.debug.enabled");
/**
* @deprecated replaced by {@link org.slf4j.Logger#isErrorEnabled()}.
......
......@@ -129,11 +129,10 @@
boolean saveLog = ParamUtils.getBooleanParameter(request,"saveLog");
boolean emailLog = ParamUtils.getBooleanParameter(request,"emailLog");
boolean debugEnabled = ParamUtils.getBooleanParameter(request,"debugEnabled");
boolean wasDebugEnabled = ParamUtils.getBooleanParameter(request,"wasDebugEnabled");
// Enable/disable debugging
if (request.getParameter("wasDebugEnabled") != null && wasDebugEnabled != debugEnabled) {
Log.setDebugEnabled(debugEnabled);
if (request.getParameter("debugEnabled") != null && debugEnabled != Log.isDebugEnabled()) {
JiveGlobals.setProperty(Log.LOG_DEBUG_ENABLED, String.valueOf(debugEnabled));
// Log the event
admin.logEvent((debugEnabled ? "enabled" : "disabled")+" debug logging", null);
response.sendRedirect("logviewer.jsp?log=debug");
......@@ -409,19 +408,18 @@ IFRAME {
<fmt:message key="logviewer.debug_log" />: &nbsp;
</td>
<td width="1%">
<input type="radio" name="debugEnabled" value="true"<%= ((debugEnabled) ? " checked" : "") %> id="de01">
<input id="de01" type="radio" name="debugEnabled" value="true" <%= debugEnabled ? " checked" : "" %>>
</td>
<td width="1%" nowrap>
<label for="de01"><fmt:message key="logviewer.enabled" /></label> &nbsp;
</td>
<td width="1%">
<input type="radio" name="debugEnabled" value="false"<%= ((!debugEnabled) ? " checked" : "") %> id="de02">
<input id="de02" type="radio" name="debugEnabled" value="false" <%= debugEnabled ? "" : " checked" %>>
</td>
<td width="1%" nowrap>
<label for="de02">Disabled</label> &nbsp;
</td>
<td width="1%">
<input type="hidden" name="wasDebugEnabled" value="<%= debugEnabled %>">
<input type="submit" name="" value="<fmt:message key="global.save_changes" />">
</td>
<td width="94%">&nbsp;</td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment