[logback-dev] svn commit: r1291 - in logback-demo/trunk/src/main: java/ch/qos/logback/demo java/ch/qos/logback/demo/statii java/ch/qos/logback/demo/util resources webapp webapp/WEB-INF webapp/css webapp/includes
noreply.seb at qos.ch
noreply.seb at qos.ch
Tue Jan 30 10:46:17 CET 2007
Author: seb
Date: Tue Jan 30 10:46:17 2007
New Revision: 1291
Added:
logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseContextAction.java
logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseContextForm.java
logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseModuleAction.java
- copied, changed from r1228, /logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ViewStatiiAction.java
logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseModuleForm.java
- copied, changed from r1228, /logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ViewStatiiForm.java
Removed:
logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ViewStatiiAction.java
logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ViewStatiiForm.java
Modified:
logback-demo/trunk/src/main/java/ch/qos/logback/demo/Constants.java
logback-demo/trunk/src/main/java/ch/qos/logback/demo/util/EnhancedStatusPrinter.java
logback-demo/trunk/src/main/resources/logback.xml
logback-demo/trunk/src/main/webapp/WEB-INF/struts-config.xml
logback-demo/trunk/src/main/webapp/WEB-INF/web.xml
logback-demo/trunk/src/main/webapp/css/pk.css
logback-demo/trunk/src/main/webapp/includes/menu.jsp
logback-demo/trunk/src/main/webapp/viewStatii.jsp
Log:
The ViewStatii page now shows all the available contexts
Modified: logback-demo/trunk/src/main/java/ch/qos/logback/demo/Constants.java
==============================================================================
--- logback-demo/trunk/src/main/java/ch/qos/logback/demo/Constants.java (original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/Constants.java Tue Jan 30 10:46:17 2007
@@ -18,6 +18,7 @@
public static final String ACCESS = "Access";
public static final String CLASSIC = "Classic";
+ public static final String CONTEXT_LIST = "ContextList";
public static final String STATUS = "Status";
Added: logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseContextAction.java
==============================================================================
--- (empty file)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseContextAction.java Tue Jan 30 10:46:17 2007
@@ -0,0 +1,43 @@
+package ch.qos.logback.demo.statii;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.demo.Constants;
+import ch.qos.logback.demo.util.EnhancedStatusPrinter;
+
+public class ChooseContextAction extends Action {
+
+ Logger logger = LoggerFactory.getLogger(ChooseModuleAction.class);
+
+ public ActionForward execute(ActionMapping actionMapping,
+ ActionForm actionForm, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ StringBuffer buf = new StringBuffer();
+
+ if (actionForm != null) {
+ ChooseContextForm form = (ChooseContextForm) actionForm;
+
+ String contextName = form.getContextName();
+ LoggerContext context = LoggerFactory.getContextSelector().getLoggerContext(contextName);
+ EnhancedStatusPrinter.print(buf, context.getStatusManager());
+ request.setAttribute(Constants.STATUS, buf.toString());
+ }
+
+ List<String> contextNames = LoggerFactory.getContextSelector().getContextNames();
+ request.setAttribute(Constants.CONTEXT_LIST, contextNames);
+
+ return actionMapping.findForward("next");
+ }
+}
\ No newline at end of file
Added: logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseContextForm.java
==============================================================================
--- (empty file)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseContextForm.java Tue Jan 30 10:46:17 2007
@@ -0,0 +1,19 @@
+package ch.qos.logback.demo.statii;
+
+import org.apache.struts.action.ActionForm;
+
+
+public class ChooseContextForm extends ActionForm {
+
+ private static final long serialVersionUID = 0L;
+
+ private String contextName = "default";
+
+ public String getContextName() {
+ return contextName;
+ }
+
+ public void setContextName(String contextName) {
+ this.contextName = contextName;
+ }
+}
Copied: logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseModuleAction.java (from r1228, /logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ViewStatiiAction.java)
==============================================================================
--- /logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ViewStatiiAction.java (original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseModuleAction.java Tue Jan 30 10:46:17 2007
@@ -1,8 +1,6 @@
package ch.qos.logback.demo.statii;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Iterator;
+import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -16,79 +14,45 @@
import ch.qos.logback.access.jetty.RequestLogImpl;
import ch.qos.logback.access.jetty.RequestLogRegistry;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.core.status.Status;
-import ch.qos.logback.core.status.StatusManager;
import ch.qos.logback.demo.Constants;
import ch.qos.logback.demo.util.EnhancedStatusPrinter;
-public class ViewStatiiAction extends Action {
+public class ChooseModuleAction extends Action {
- Logger logger = LoggerFactory.getLogger(ViewStatiiAction.class);
+ Logger logger = LoggerFactory.getLogger(ChooseModuleAction.class);
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) throws Exception {
- LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
StringBuffer buf = new StringBuffer();
-
+
if (actionForm != null) {
- ViewStatiiForm form = (ViewStatiiForm) actionForm;
+ ChooseModuleForm form = (ChooseModuleForm) actionForm;
- String sm = form.getStatusManager();
+ String sm = form.getModuleName();
if (sm != null && sm.equals(Constants.ACCESS)) {
- RequestLogImpl requestLog = RequestLogRegistry.get(Constants.REQUESTLOG_NAME);
- if(requestLog != null) {
- print(buf, requestLog.getStatusManager());
- } else {
- buf.append("Could not get "+Constants.REQUESTLOG_NAME);
- }
+// try {
+ RequestLogImpl requestLog = RequestLogRegistry.get(Constants.REQUESTLOG_NAME);
+ if (requestLog != null) {
+ EnhancedStatusPrinter.print(buf, requestLog.getStatusManager());
+ } else {
+ buf.append("Could not get " + Constants.REQUESTLOG_NAME);
+ }
+// } catch(NoClassDefFoundError error) {
+// //in case the RequestLogRegistry is not available
+// buf.append("Could not get " + Constants.REQUESTLOG_NAME);
+// }
+
+ request.setAttribute(Constants.STATUS, buf.toString());
+
} else {
- print(buf, lc.getStatusManager());
+ List<String> contextNames = LoggerFactory.getContextSelector()
+ .getContextNames();
+ request.setAttribute(Constants.CONTEXT_LIST, contextNames);
}
-
- } else {
- print(buf, lc.getStatusManager());
}
- request.setAttribute(Constants.STATUS, buf.toString());
return actionMapping.findForward("next");
}
-
- private void print(StringBuffer buf, StatusManager sm) {
-
- Iterator it = sm.iterator();
- while (it.hasNext()) {
- Status s = (Status) it.next();
- print(buf, "", s);
- }
- }
-
- private void print(StringBuffer buf, String indentation, Status s) {
- String prefix;
- if(s.hasChildren()) {
- prefix = indentation + "+ ";
- } else {
- prefix = indentation + "|-";
- }
- buf.append(prefix);
- buf.append(EnhancedStatusPrinter.print(s));
- buf.append("\r\n");
-
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- if (s.getThrowable() != null) {
- s.getThrowable().printStackTrace(pw);
- buf.append(sw.getBuffer());
- }
- if(s.hasChildren()) {
- Iterator<Status> ite = s.iterator();
- while(ite.hasNext()) {
- Status child = ite.next();
- print(buf, indentation+" ", child);
- }
-
- }
- }
}
\ No newline at end of file
Copied: logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseModuleForm.java (from r1228, /logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ViewStatiiForm.java)
==============================================================================
--- /logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ViewStatiiForm.java (original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseModuleForm.java Tue Jan 30 10:46:17 2007
@@ -5,17 +5,17 @@
import ch.qos.logback.demo.Constants;
-public class ViewStatiiForm extends ActionForm {
+public class ChooseModuleForm extends ActionForm {
private static final long serialVersionUID = 0L;
- private String statusManager = Constants.CLASSIC;
+ private String moduleName = Constants.CLASSIC;
- public String getStatusManager() {
- return statusManager;
+ public String getModuleName() {
+ return moduleName;
}
- public void setStatusManager(String statusManager) {
- this.statusManager = statusManager;
+ public void setModuleName(String moduleName) {
+ this.moduleName = moduleName;
}
}
Modified: logback-demo/trunk/src/main/java/ch/qos/logback/demo/util/EnhancedStatusPrinter.java
==============================================================================
--- logback-demo/trunk/src/main/java/ch/qos/logback/demo/util/EnhancedStatusPrinter.java (original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/util/EnhancedStatusPrinter.java Tue Jan 30 10:46:17 2007
@@ -1,9 +1,13 @@
package ch.qos.logback.demo.util;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.text.SimpleDateFormat;
+import java.util.Iterator;
import ch.qos.logback.classic.pattern.ClassNameAbbreviator;
import ch.qos.logback.core.status.Status;
+import ch.qos.logback.core.status.StatusManager;
public class EnhancedStatusPrinter {
@@ -41,4 +45,41 @@
return buf.toString();
}
+
+ public static void print(StringBuffer buf, StatusManager sm) {
+
+ Iterator it = sm.iterator();
+ while (it.hasNext()) {
+ Status s = (Status) it.next();
+ print(buf, "", s);
+ }
+ }
+
+ public static void print(StringBuffer buf, String indentation, Status s) {
+ String prefix;
+ if(s.hasChildren()) {
+ prefix = indentation + "+ ";
+ } else {
+ prefix = indentation + "|-";
+ }
+ buf.append(prefix);
+ buf.append(EnhancedStatusPrinter.print(s));
+ buf.append("\r\n");
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ if (s.getThrowable() != null) {
+ s.getThrowable().printStackTrace(pw);
+ buf.append(sw.getBuffer());
+ }
+ if(s.hasChildren()) {
+ Iterator<Status> ite = s.iterator();
+ while(ite.hasNext()) {
+ Status child = ite.next();
+ print(buf, indentation+" ", child);
+ }
+
+ }
+ }
+
}
Modified: logback-demo/trunk/src/main/resources/logback.xml
==============================================================================
--- logback-demo/trunk/src/main/resources/logback.xml (original)
+++ logback-demo/trunk/src/main/resources/logback.xml Tue Jan 30 10:46:17 2007
@@ -75,7 +75,7 @@
<!-- JMX Configurator
<jmxConfigurator />
-->
-
+ <jmxConfigurator />
<root>
<level value="DEBUG" />
Modified: logback-demo/trunk/src/main/webapp/WEB-INF/struts-config.xml
==============================================================================
--- logback-demo/trunk/src/main/webapp/WEB-INF/struts-config.xml (original)
+++ logback-demo/trunk/src/main/webapp/WEB-INF/struts-config.xml Tue Jan 30 10:46:17 2007
@@ -18,8 +18,11 @@
<form-bean name="primeForm"
type="ch.qos.logback.demo.prime.PrimeForm" />
- <form-bean name="viewStatiiForm"
- type="ch.qos.logback.demo.statii.ViewStatiiForm" />
+ <form-bean name="chooseModuleForm"
+ type="ch.qos.logback.demo.statii.ChooseModuleForm" />
+
+ <form-bean name="chooseContextForm"
+ type="ch.qos.logback.demo.statii.ChooseContextForm" />
<form-bean name="reloadConfigForm"
type="ch.qos.logback.demo.reload.ReloadConfigForm" />
@@ -77,12 +80,18 @@
<forward name="next" path="/logout.jsp" />
</action>
- <action path="/ViewStatii"
- type="ch.qos.logback.demo.statii.ViewStatiiAction"
- name="viewStatiiForm" scope="request">
+ <action path="/ChooseModule"
+ type="ch.qos.logback.demo.statii.ChooseModuleAction"
+ name="chooseModuleForm" scope="request">
<forward name="next" path="/viewStatii.jsp" />
</action>
+ <action path="/ChooseContext"
+ type="ch.qos.logback.demo.statii.ChooseContextAction"
+ name="chooseContextForm" scope="request">
+ <forward name="next" path="/viewStatii.jsp" />
+ </action>
+
<action path="/ReloadConfig"
type="ch.qos.logback.demo.reload.ReloadConfigAction"
name="reloadConfigForm" scope="request">
Modified: logback-demo/trunk/src/main/webapp/WEB-INF/web.xml
==============================================================================
--- logback-demo/trunk/src/main/webapp/WEB-INF/web.xml (original)
+++ logback-demo/trunk/src/main/webapp/WEB-INF/web.xml Tue Jan 30 10:46:17 2007
@@ -5,6 +5,21 @@
<display-name>logback-demo</display-name>
+ <!-- Used when testing multiple contexts -->
+ <env-entry>
+ <description>JNDI logging context for this app</description>
+ <env-entry-name>logback/context-name</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>DemoContext</env-entry-value>
+ </env-entry>
+
+ <env-entry>
+ <description>URL for configuring logback context</description>
+ <env-entry-name>logback/configuration-resource</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>logback-demo.xml</env-entry-value>
+ </env-entry>
+
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
Modified: logback-demo/trunk/src/main/webapp/css/pk.css
==============================================================================
--- logback-demo/trunk/src/main/webapp/css/pk.css (original)
+++ logback-demo/trunk/src/main/webapp/css/pk.css Tue Jan 30 10:46:17 2007
@@ -1,98 +1,129 @@
body {
- margin-top: 10px;
- margin-left: 10px;
- font-size: large;
- background-image: url(../images/lblogo.jpg);
- background-repeat: no-repeat;
- background-position: left top;
+ margin-top: 10px;
+ margin-left: 10px;
+ font-size: large;
+ background-image: url(../images/lblogo.jpg);
+ background-repeat: no-repeat;
+ background-position: left top;
}
h2 {
- text-align: center;
- margin-top: 1em;
+ text-align: center;
+ margin-top: 1em;
}
-table {
- margin-left: 2em;
- margin-right: 2em;
- /*border-left: 2px solid #AAA;
+table {
+ margin-left: 2em;
+ margin-right: 2em;
+ /*border-left: 2px solid #AAA;
border-right: 2px solid #AAA;*/
}
div.content {
- margin-top:80px;
- margin-left:220px;
+ margin-top: 80px;
+ margin-left: 220px;
}
div.content_full {
- margin-top:80px;
- margin-left:10px;
+ margin-top: 80px;
+ margin-left: 10px;
+}
+
+div.statiiMenus {
+ width: 300px;
+ /*float: right;*/
+ display: block;
+ padding-top: 40px;
+ padding-left: 20ex;
+ padding-right: 1ex;
+ margin-left: 3em;
+ margin-right: 3em;
}
table.nav {
- margin-top: 40px;
- width: 10em;
- float: left;
- overflow: auto;
+ margin-top: 40px;
+ width: 10em;
+ float: left;
+ overflow: auto;
+}
+
+TR.even {
+ background: #FFFFFF;
}
-TR.even { background: #FFFFFF; }
-TR.odd { background: #EAEAEA; }
-TR.error {font-weight: bold; color: #FF4040 }
+TR.odd {
+ background: #EAEAEA;
+}
+
+TR.error {
+ font-weight: bold;
+ color: #FF4040
+}
-
-TD {
- padding-right: 1ex;
- padding-left: 1ex;
- padding-top: 0ex;
- /*border-right: 2px solid #AAA;*/
+TD {
+ padding-right: 1ex;
+ padding-left: 1ex;
+ padding-top: 0ex;
+ /*border-right: 2px solid #AAA;*/
}
-TD.Date { text-align: right; font-family: courier, monospace; font-size: smaller; }
+TD.Date {
+ text-align: right;
+ font-family: courier, monospace;
+ font-size: smaller;
+}
-TD.Thread { text-align: left; }
-TD.Level { text-align: right; }
-TD.Logger { text-align: left; }
+TD.Thread {
+ text-align: left;
+}
-TR.header { background: #596ED5; color: #FFF; font-weight: bold; font-size: larger; }
+TD.Level {
+ text-align: right;
+}
+TD.Logger {
+ text-align: left;
+}
-TD.Exception {
- background: #A2AEE8;
- font-family: courier, monospace;
+TR.header {
+ background: #596ED5;
+ color: #FFF;
+ font-weight: bold;
+ font-size: larger;
}
+TD.Exception {
+ background: #A2AEE8;
+ font-family: courier, monospace;
+}
TD.sexy {
- border-top: 2px solid #DDD;
- border-left: 2px solid #DDD;
- border-right: 2px solid #888;
- border-bottom: 2px solid #888;
+ border-top: 2px solid #DDD;
+ border-left: 2px solid #DDD;
+ border-right: 2px solid #888;
+ border-bottom: 2px solid #888;
}
.red {
- color: #CC0000;
- }
-
- .orange {
- color: #FF6600;
- }
-
-A.sexy, INPUT.sexy, span.sexy {
- /*background: #FFF; */
- color: #0079C5;
-
- font-weight: bold;
- font-family: "Comic Sans MS", sans-serif;
- font-size: 14px;
- white-space: nowrap;
-
- padding: 0px 1em 0px 1em;
- margin: 5px 0px 3px 0px;
-
- text-decoration: none;
+ color: #CC0000;
+}
+
+.orange {
+ color: #FF6600;
+}
+
+A.sexy,INPUT.sexy,span.sexy { /*background: #FFF; */
+ color: #0079C5;
+ font-weight: bold;
+ font-family: "Comic Sans MS", sans-serif;
+ font-size: 14px;
+ white-space: nowrap;
+ padding: 0px 1em 0px 1em;
+ margin: 5px 0px 3px 0px;
+ text-decoration: none;
}
-TD.sexy:hover, A.sexy:hover, INPUT.sexy:hover, INPUT.sexy_hover, span.sexy:hover {
- background: #E0E0EF;
+TD.sexy:hover,A.sexy:hover,INPUT.sexy:hover,INPUT.sexy_hover,span.sexy:hover
+ {
+ background: #E0E0EF;
}
\ No newline at end of file
Modified: logback-demo/trunk/src/main/webapp/includes/menu.jsp
==============================================================================
--- logback-demo/trunk/src/main/webapp/includes/menu.jsp (original)
+++ logback-demo/trunk/src/main/webapp/includes/menu.jsp Tue Jan 30 10:46:17 2007
@@ -3,7 +3,7 @@
<table class="nav">
<tr><td class="sexy"><a href="index.jsp" class="sexy">Home</a></td></tr>
<tr><td class="sexy"><a href="login.jsp" class="sexy">Login</a></td></tr>
- <tr><td class="sexy"><a href="ViewStatii.do" class="sexy">View Statii</a></td></tr>
+ <tr><td class="sexy"><a href="ChooseModule.do" class="sexy">View Statii</a></td></tr>
<tr><td class="sexy"><a href="lastLog/" class="sexy">View logs</a></td></tr>
<tr><td class="sexy"><a href="prime.jsp" class="sexy">Prime number</a></td></tr>
<tr><td class="sexy"><a href="lottery.jsp" class="sexy">Play the lottery</a></td></tr>
Modified: logback-demo/trunk/src/main/webapp/viewStatii.jsp
==============================================================================
--- logback-demo/trunk/src/main/webapp/viewStatii.jsp (original)
+++ logback-demo/trunk/src/main/webapp/viewStatii.jsp Tue Jan 30 10:46:17 2007
@@ -3,34 +3,49 @@
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
+<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head>
<LINK REL=StyleSheet HREF="css/pk.css" />
<SCRIPT language="javascript" type="text/javascript">
- function statusSubmit() {
- document.viewStatiiForm.submit();
+ function moduleSubmit() {
+ document.chooseModuleForm.submit();
}
- </SCRIPT>
+ </SCRIPT>
</head>
<body>
<h2>Statii</h2>
<%@include file="includes/mini-menu.jsp" %>
-<div class="content_full">
-<html:form action="/ViewStatii">
+
+
+<div class="statiiMenus">
+<html:form action="/ChooseModule">
<html:errors />
-<p><html:select property="statusManager" onchange="statusSubmit();">
+<html:select property="moduleName" onchange="moduleSubmit();">
<html:option value="<%=Constants.ACCESS %>"><%=Constants.ACCESS %></html:option>
<html:option value="<%=Constants.CLASSIC %>"><%=Constants.CLASSIC %></html:option>
-</html:select></p>
+</html:select>
</html:form>
+<logic:notEmpty name="<%=Constants.CONTEXT_LIST %>">
+<html:form action="/ChooseContext">
+<html:errors />
+<html:select property="contextName">
+<html:options name="<%=Constants.CONTEXT_LIST %>" ></html:options>
+</html:select>
+<html:submit>Display</html:submit>
+</html:form>
+</logic:notEmpty>
+</div>
+
+<div class="content_full">
+
+<logic:notEmpty name="<%=Constants.STATUS %>">
<pre>
-<%
-String statuses = (String)request.getAttribute(Constants.STATUS);
-out.print(statuses);
-%>
+<bean:write name="<%=Constants.STATUS %>"/>
</pre>
+</logic:notEmpty>
</div>
</body>
More information about the logback-dev
mailing list