Get log4j working.
This commit is contained in:
parent
7e7be6c54e
commit
48d7ef36e9
|
@ -0,0 +1,5 @@
|
||||||
|
log4j.rootLogger=INFO, stdout
|
||||||
|
|
||||||
|
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||||
|
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
|
@ -31,6 +31,7 @@ Administration tools.
|
||||||
<%@ page import="com.google.inject.Key" %>
|
<%@ page import="com.google.inject.Key" %>
|
||||||
<%@ page import="com.google.inject.TypeLiteral" %>
|
<%@ page import="com.google.inject.TypeLiteral" %>
|
||||||
<%@ page import="net.socialgamer.cah.RequestWrapper" %>
|
<%@ page import="net.socialgamer.cah.RequestWrapper" %>
|
||||||
|
<%@ page import="net.socialgamer.cah.StartupUtils" %>
|
||||||
<%@ page import="net.socialgamer.cah.CahModule.BanList" %>
|
<%@ page import="net.socialgamer.cah.CahModule.BanList" %>
|
||||||
<%@ page import="net.socialgamer.cah.Constants.DisconnectReason" %>
|
<%@ page import="net.socialgamer.cah.Constants.DisconnectReason" %>
|
||||||
<%@ page import="net.socialgamer.cah.Constants.LongPollEvent" %>
|
<%@ page import="net.socialgamer.cah.Constants.LongPollEvent" %>
|
||||||
|
@ -116,6 +117,11 @@ if (unbanParam != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String reloadLog4j = request.getParameter("reloadLog4j");
|
||||||
|
if ("true".equals(reloadLog4j)) {
|
||||||
|
StartupUtils.reconfigureLogging(this.getServletContext());
|
||||||
|
}
|
||||||
|
|
||||||
%>
|
%>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
@ -218,6 +224,7 @@ User list:
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
|
// TODO remove this "verbose logging" crap now that log4j is working.
|
||||||
Boolean verboseDebugObj = (Boolean) servletContext.getAttribute(StartupUtils.VERBOSE_DEBUG);
|
Boolean verboseDebugObj = (Boolean) servletContext.getAttribute(StartupUtils.VERBOSE_DEBUG);
|
||||||
boolean verboseDebug = verboseDebugObj != null ? verboseDebugObj.booleanValue() : false;
|
boolean verboseDebug = verboseDebugObj != null ? verboseDebugObj.booleanValue() : false;
|
||||||
%>
|
%>
|
||||||
|
@ -225,6 +232,9 @@ boolean verboseDebug = verboseDebugObj != null ? verboseDebugObj.booleanValue()
|
||||||
Verbose logging is currently <strong><%= verboseDebug ? "ON" : "OFF" %></strong>.
|
Verbose logging is currently <strong><%= verboseDebug ? "ON" : "OFF" %></strong>.
|
||||||
<a href="?verbose=on">Turn on.</a> <a href="?verbose=off">Turn off.</a>
|
<a href="?verbose=on">Turn on.</a> <a href="?verbose=off">Turn off.</a>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<a href="?reloadLog4j=true">Reload log4j.properties.</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -29,6 +29,8 @@ import java.util.Timer;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
|
|
||||||
|
import org.apache.log4j.PropertyConfigurator;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.servlet.GuiceServletContextListener;
|
import com.google.inject.servlet.GuiceServletContextListener;
|
||||||
|
@ -102,6 +104,13 @@ public class StartupUtils extends GuiceServletContextListener {
|
||||||
context.setAttribute(PING_TIMER_NAME, timer);
|
context.setAttribute(PING_TIMER_NAME, timer);
|
||||||
context.setAttribute(INJECTOR, injector);
|
context.setAttribute(INJECTOR, injector);
|
||||||
context.setAttribute(DATE_NAME, serverStarted);
|
context.setAttribute(DATE_NAME, serverStarted);
|
||||||
|
|
||||||
|
reconfigureLogging(contextEvent.getServletContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reconfigureLogging(final ServletContext context) {
|
||||||
|
PropertyConfigurator.configure(context.getRealPath(
|
||||||
|
"/WEB-INF/log4j.properties"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,7 +25,6 @@ package net.socialgamer.cah.handlers;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
@ -34,6 +33,8 @@ import net.socialgamer.cah.Constants.ErrorCode;
|
||||||
import net.socialgamer.cah.Constants.ReturnableData;
|
import net.socialgamer.cah.Constants.ReturnableData;
|
||||||
import net.socialgamer.cah.RequestWrapper;
|
import net.socialgamer.cah.RequestWrapper;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementations of this interface MUST also have a public static final String OP. There will be
|
* Implementations of this interface MUST also have a public static final String OP. There will be
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class KickHandler extends Handler {
|
||||||
kickUser.enqueueMessage(qm);
|
kickUser.enqueueMessage(qm);
|
||||||
|
|
||||||
connectedUsers.removeUser(kickUser, DisconnectReason.KICKED);
|
connectedUsers.removeUser(kickUser, DisconnectReason.KICKED);
|
||||||
logger.info(String.format("Kicking %s by request of %s", kickUser.getNickname(),
|
logger.warn(String.format("Kicking %s by request of %s", kickUser.getNickname(),
|
||||||
user.getNickname()));
|
user.getNickname()));
|
||||||
|
|
||||||
return new HashMap<ReturnableData, Object>();
|
return new HashMap<ReturnableData, Object>();
|
||||||
|
|
Loading…
Reference in New Issue