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.TypeLiteral" %>
|
||||
<%@ page import="net.socialgamer.cah.RequestWrapper" %>
|
||||
<%@ page import="net.socialgamer.cah.StartupUtils" %>
|
||||
<%@ page import="net.socialgamer.cah.CahModule.BanList" %>
|
||||
<%@ page import="net.socialgamer.cah.Constants.DisconnectReason" %>
|
||||
<%@ page import="net.socialgamer.cah.Constants.LongPollEvent" %>
|
||||
|
@ -116,6 +117,11 @@ if (unbanParam != null) {
|
|||
return;
|
||||
}
|
||||
|
||||
String reloadLog4j = request.getParameter("reloadLog4j");
|
||||
if ("true".equals(reloadLog4j)) {
|
||||
StartupUtils.reconfigureLogging(this.getServletContext());
|
||||
}
|
||||
|
||||
%>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
@ -218,6 +224,7 @@ User list:
|
|||
</table>
|
||||
|
||||
<%
|
||||
// TODO remove this "verbose logging" crap now that log4j is working.
|
||||
Boolean verboseDebugObj = (Boolean) servletContext.getAttribute(StartupUtils.VERBOSE_DEBUG);
|
||||
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>.
|
||||
<a href="?verbose=on">Turn on.</a> <a href="?verbose=off">Turn off.</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="?reloadLog4j=true">Reload log4j.properties.</a>
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -29,6 +29,8 @@ import java.util.Timer;
|
|||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.servlet.GuiceServletContextListener;
|
||||
|
@ -102,6 +104,13 @@ public class StartupUtils extends GuiceServletContextListener {
|
|||
context.setAttribute(PING_TIMER_NAME, timer);
|
||||
context.setAttribute(INJECTOR, injector);
|
||||
context.setAttribute(DATE_NAME, serverStarted);
|
||||
|
||||
reconfigureLogging(contextEvent.getServletContext());
|
||||
}
|
||||
|
||||
public static void reconfigureLogging(final ServletContext context) {
|
||||
PropertyConfigurator.configure(context.getRealPath(
|
||||
"/WEB-INF/log4j.properties"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,6 @@ package net.socialgamer.cah.handlers;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
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.RequestWrapper;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
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()));
|
||||
|
||||
return new HashMap<ReturnableData, Object>();
|
||||
|
|
Loading…
Reference in New Issue