Commit 7c1524b3 authored by guus's avatar guus

OF-506: Use standard Log4j configuration to control Jetty-related logging.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@12944 b35dd754-fafc-0310-a699-88a17e54d16e
parent 6322163e
......@@ -55,6 +55,11 @@
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<!-- OF-506: Jetty INFO messages are generally not useful. Ignore them by default. -->
<logger name="org.eclipse.jetty">
<level value="warn" />
</logger>
<root>
<level value="info" />
......
......@@ -81,8 +81,6 @@ public class AdminConsolePlugin implements Plugin {
public AdminConsolePlugin() {
contexts = new ContextHandlerCollection();
// Configure Jetty logging to a more reasonable default.
System.setProperty("org.eclipse.jetty.util.log.class", "org.jivesoftware.util.log.util.JettyLog");
// JSP 2.0 uses commons-logging, so also override that implementation.
System.setProperty("org.apache.commons.logging.LogFactory", "org.jivesoftware.util.log.util.CommonsLogFactory");
}
......
......@@ -91,8 +91,6 @@ public final class HttpBindManager {
}
private HttpBindManager() {
// Configure Jetty logging to a more reasonable default.
System.setProperty("org.eclipse.jetty.util.log.class", "org.jivesoftware.util.log.util.JettyLog");
// JSP 2.0 uses commons-logging, so also override that implementation.
System.setProperty("org.apache.commons.logging.LogFactory", "org.jivesoftware.util.log.util.CommonsLogFactory");
......
/**
* $RCSfile$
* $Revision: 3144 $
* $Date: 2005-12-01 14:20:11 -0300 (Thu, 01 Dec 2005) $
*
* Copyright (C) 2004-2008 Jive Software. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.util.log.util;
import org.jivesoftware.util.JiveGlobals;
import org.eclipse.jetty.util.log.Logger;
import org.slf4j.LoggerFactory;
/**
* A Logger implementation to override the default Jetty logging behavior. All log statements
* are written to the Openfire logs. Info level logging is sent to debug.
*/
public class JettyLog implements org.eclipse.jetty.util.log.Logger {
private static final org.slf4j.Logger Log = LoggerFactory.getLogger(JettyLog.class);
/**
* Only enable Jetty debug logging if it's specifically enabled. Otherwise, Jetty debug logs
* pollute the Openfire debug log with too much data.
*/
private boolean debugEnabled = JiveGlobals.getBooleanProperty("jetty.debugEnabled");
public boolean isDebugEnabled() {
return debugEnabled && Log.isDebugEnabled();
}
public String getName() {
return "JettyLog";
}
public void setDebugEnabled(boolean b) {
// Do nothing.
}
public void info(String string, Object... object) {
// Send info log messages to debug because they are generally not useful.
Log.debug("JettyLog: " + object);
}
public void info(String string, Throwable throwable) {
Log.debug("JettyLog: " + string);
}
public void info(Throwable throwable) {
// do nothing
}
public void debug(String string, Object... object) {
Log.debug("JettyLog: " + object);
}
public void debug(String string, Throwable throwable) {
Log.debug(string);
}
public void debug(Throwable throwable) {
// do nothing
}
public void warn(String string, Object... object) {
Log.warn("JettyLog: "+ object);
}
public void warn(String string, Throwable throwable) {
Log.warn(string);
}
public void warn(Throwable throwable) {
// do nothing
}
public void ignore(Throwable throwable) {
// do nothing
}
public Logger getLogger(String string) {
return new JettyLog();
}
private String format(String msg, Object arg0, Object arg1) {
int sub0 = msg.indexOf("{}");
int sub1 = (sub0 > 0) ? ( 0 ) : ( msg.indexOf("{}") );
if (arg0 != null && sub0 > 0)
msg = msg.substring(0,sub0)+arg0+msg.substring(sub0+2);
if (arg1 != null && sub1 > 0)
msg = msg.substring(0,sub1)+arg1+msg.substring(sub1+2);
return msg;
}
}
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