Permalink
Browse files

Adding basic logging servlet

  • Loading branch information...
1 parent 9fb9af6 commit ddf20ab3aa80e614e261c896943d4445f17735f6 @kylape committed Dec 3, 2012
No changes.
@@ -0,0 +1,5 @@
+###Basic logging servlet
+
+This servlet simply logs to two different `java.util.logging.Logger`s: `com.redhat.gss.logging.LoggingServlet` and `some.fun.class.Name`. The statements are really long so testing for log rotation won't take as many invocations of the servlet.
+
+To invoke the servlet, run `curl curl http://localhost:8080/loggingServlet/logging`. To invoke indefinitely, run `for (( ; ; )); do curl http://localhost:8080/loggingServlet/logging; done`.
@@ -0,0 +1,32 @@
+/*
+ * To the extent possible under law, Red Hat, Inc. has dedicated all copyright
+ * to this software to the public domain worldwide, pursuant to the CC0 Public
+ * Domain Dedication. This software is distributed without any warranty. See
+ * <http://creativecommons.org/publicdomain/zero/1.0/>.
+ */
+package com.redhat.gss.logging;
+
+import java.util.logging.Logger;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServlet;
+
+//@javax.servlet.annotation.WebServlet(urlPatterns={"/*"})
+public class LoggingServlet extends HttpServlet
+{
+ private Logger log = Logger.getLogger(this.getClass().getName());
+ private Logger log2 = Logger.getLogger("some.fun.class.Name");
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ log.info("This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement. This is a really big log statement.");
+
+ log2.fine("This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement. This is a really fine log statement.");
+ }
+}
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ To the extent possible under law, Red Hat, Inc. has dedicated all copyright
+ to this software to the public domain worldwide, pursuant to the CC0 Public
+ Domain Dedication. This software is distributed without any warranty. See
+ <http://creativecommons.org/publicdomain/zero/1.0/>.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
+ <servlet>
+ <servlet-name>Logging</servlet-name>
+ <servlet-class>com.redhat.gss.logging.LoggingServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Logging</servlet-name>
+ <url-pattern>/logging</url-pattern>
+ </servlet-mapping>
+</web-app>
Oops, something went wrong.

0 comments on commit ddf20ab

Please sign in to comment.