├── .gitignore ├── src ├── main │ ├── webapp │ │ ├── images │ │ │ └── lblogo.jpg │ │ ├── includes │ │ │ ├── mini-menu.jsp │ │ │ ├── user.jsp │ │ │ └── menu.jsp │ │ ├── looser.jsp │ │ ├── winner.jsp │ │ ├── lottery.jsp │ │ ├── logout.jsp │ │ ├── prime.jsp │ │ ├── primeResults.jsp │ │ ├── login.jsp │ │ ├── reload.jsp │ │ ├── WEB-INF │ │ │ ├── tiles-defs.xml │ │ │ ├── validation.xml │ │ │ ├── web.xml │ │ │ ├── struts-config.xml │ │ │ ├── struts-tiles.tld │ │ │ ├── struts-bean.tld │ │ │ ├── validator-rules.xml │ │ │ └── struts-logic.tld │ │ ├── viewStatii.jsp │ │ ├── index.jsp │ │ └── css │ │ │ └── pk.css │ ├── resources │ │ ├── parts │ │ │ ├── cyclic.xml │ │ │ ├── trace.xml │ │ │ ├── mdc_turbo_filter.xml │ │ │ ├── cyclic-with-evaluator.xml │ │ │ ├── sifting.xml │ │ │ └── logback-basic.xml │ │ ├── logback.xml │ │ └── MessageResources.properties │ └── java │ │ └── ch │ │ └── qos │ │ └── logback │ │ └── demo │ │ ├── prime │ │ ├── NumberCruncher.java │ │ ├── PrimeForm.java │ │ ├── PrimeAction.java │ │ └── NumberCruncherImpl.java │ │ ├── statii │ │ ├── ChooseContextForm.java │ │ ├── ChooseModuleForm.java │ │ ├── ChooseContextAction.java │ │ └── ChooseModuleAction.java │ │ ├── reload │ │ ├── ReloadConfigForm.java │ │ └── ReloadConfigAction.java │ │ ├── LoggingTask.java │ │ ├── Runner.java │ │ ├── lottery │ │ ├── LotteryForm.java │ │ └── LotteryAction.java │ │ ├── login │ │ ├── LogoutAction.java │ │ ├── LoginForm.java │ │ └── LoginAction.java │ │ ├── Constants.java │ │ ├── ContextListener.java │ │ ├── UserServletFilter.java │ │ ├── util │ │ ├── HTMLUtil.java │ │ └── EnhancedStatusPrinter.java │ │ └── ViewLastLog.java └── etc │ ├── parts │ ├── counting_filter.xml │ ├── socket.xml │ ├── logback-access-MINI.xml │ ├── smtp.xml │ ├── loto.xml │ ├── logback-access-image-filter.xml │ ├── jetty-jmx.xml │ └── logback-access-FULL.xml │ ├── logback-access.xml │ └── jetty.xml └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | .settings 2 | target 3 | .classpath 4 | .project 5 | *~ 6 | .idea 7 | *.iml 8 | -------------------------------------------------------------------------------- /src/main/webapp/images/lblogo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eric-bixby/logback-demo/master/src/main/webapp/images/lblogo.jpg -------------------------------------------------------------------------------- /src/etc/parts/counting_filter.xml: -------------------------------------------------------------------------------- 1 | 2 | countingFilter 3 | 4 | -------------------------------------------------------------------------------- /src/main/resources/parts/cyclic.xml: -------------------------------------------------------------------------------- 1 | 3 | 512 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/resources/parts/trace.xml: -------------------------------------------------------------------------------- 1 | 2 | TRACE 3 | TRACE 4 | DENY 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/resources/parts/mdc_turbo_filter.xml: -------------------------------------------------------------------------------- 1 | 2 | username 3 | sebastien 4 | ACCEPT 5 | -------------------------------------------------------------------------------- /src/etc/parts/socket.xml: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /src/main/webapp/includes/mini-menu.jsp: -------------------------------------------------------------------------------- 1 | <%@page import="ch.qos.logback.demo.Constants"%> 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/etc/parts/logback-access-MINI.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %h %l %u %t \"%r\" %s %b 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/prime/NumberCruncher.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.prime; 2 | 3 | import java.rmi.Remote; 4 | import java.rmi.RemoteException; 5 | 6 | 7 | /** 8 | * NumberCruncher factors positive integers. 9 | */ 10 | public interface NumberCruncher extends Remote { 11 | /** 12 | * Factor a positive integer number and return its 13 | * distinct factor's as an integer array. 14 | * */ 15 | Long[] factor(long number) throws RemoteException; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/statii/ChooseContextForm.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.statii; 2 | 3 | import org.apache.struts.action.ActionForm; 4 | 5 | 6 | public class ChooseContextForm extends ActionForm { 7 | 8 | private static final long serialVersionUID = 0L; 9 | 10 | private String contextName = "default"; 11 | 12 | public String getContextName() { 13 | return contextName; 14 | } 15 | 16 | public void setContextName(String contextName) { 17 | this.contextName = contextName; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/statii/ChooseModuleForm.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.statii; 2 | 3 | import org.apache.struts.action.ActionForm; 4 | 5 | import ch.qos.logback.demo.Constants; 6 | 7 | 8 | public class ChooseModuleForm extends ActionForm { 9 | 10 | private static final long serialVersionUID = 0L; 11 | 12 | private String moduleName = Constants.CLASSIC; 13 | 14 | public String getModuleName() { 15 | return moduleName; 16 | } 17 | 18 | public void setModuleName(String moduleName) { 19 | this.moduleName = moduleName; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/parts/cyclic-with-evaluator.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | logger.contains("LoggingTask") && 7 | message.contains("Howdydy-diddly-ho") && 8 | (timeStamp - loggerContext.getBirthTime()) >= 20000 9 | 10 | 11 | DENY 12 | 13 | 512 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/reload/ReloadConfigForm.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.reload; 2 | 3 | import org.apache.struts.action.ActionForm; 4 | 5 | import ch.qos.logback.demo.Constants; 6 | 7 | 8 | public class ReloadConfigForm extends ActionForm { 9 | 10 | private static final long serialVersionUID = 0L; 11 | 12 | private String moduleName = Constants.CLASSIC; 13 | 14 | public String getModuleName() { 15 | return moduleName; 16 | } 17 | 18 | public void setModuleName(String moduleName) { 19 | this.moduleName = moduleName; 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/etc/parts/smtp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | %h%l%u%t%r%s%b 7 | 8 | 9 | 10 | winner.jsp 11 | 12 | ceki@qos.ch 13 | gmail-smtp-in.l.google.com 14 | Winner detected 15 | sebastien.pennec@gmail.com 16 | ceki.gulcu@gmail.com 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/webapp/includes/user.jsp: -------------------------------------------------------------------------------- 1 | <%@page import="ch.qos.logback.demo.Constants"%> 2 | <%@page import="org.slf4j.MDC"%> 3 | <% 4 | String username = (String)session.getAttribute(Constants.USERID_SESSION_KEY); 5 | String text; 6 | if (username == null) { 7 | text = "No user logged in."; 8 | } else { 9 | text = "User: " + username; 10 | } 11 | %> 12 | 13 | 14 | <% 15 | String mdcUserid = MDC.get(Constants.USERID_MDC_KEY); 16 | String mdcText; 17 | if (mdcUserid == null) { 18 | mdcText = "MDC userid is null"; 19 | } else { 20 | mdcText = "MDC userid is " + mdcUserid; 21 | } 22 | %> 23 | 24 | 25 | <%=text %> 26 |
27 | <%=mdcText %> -------------------------------------------------------------------------------- /src/main/resources/parts/sifting.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | userid 5 | unknown 6 | 7 | 8 | 10 | ${userid}.log 11 | false 12 | 13 | 14 | %d [%thread] %-55(%-5level %10mdc %logger{35}) - %msg%n 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/webapp/looser.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> 5 | <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 6 | 7 | 8 | 9 | 10 | 11 | Lottery 12 | 13 |

Too bad...

14 | <%@include file="includes/menu.jsp"%> 15 | 16 |
17 |

Oops, is not a winning number...

18 |
Play again!
19 |
20 | 21 | -------------------------------------------------------------------------------- /src/main/webapp/winner.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> 5 | <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Lottery Winner 14 | 15 |

Winner!

16 | <%@include file="includes/menu.jsp"%> 17 | 18 |
19 | Congratulations, you've won the Grand Prize! 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/webapp/lottery.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> 5 | <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 6 | 7 | 8 | 9 | 10 | Lottery 11 | 12 |

Play the Lottery

13 | <%@include file="includes/menu.jsp"%> 14 |
15 | 16 |

Please play a number.

17 | 18 | 19 | 20 |

21 | 22 |

Submit

23 |
24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /src/etc/parts/loto.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | url.matches(request.getRequestURL().toString()) 7 | 8 | 9 | lotto.do 10 | false 11 | 12 | 13 | ACCEPT 14 | DENY 15 | 16 | 17 | 18 | LOTTO: %A [%r] Guess=%reqParameter{guessed_number} 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/etc/logback-access.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %fullRequest%n%n%fullResponse 8 | 9 | 10 | 11 | 12 | /tmp/access.log 13 | 14 | access.%d{yyyy-MM-dd}.log.zip 15 | 16 | 17 | 18 | %fullRequest%n%n%fullResponse 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/LoggingTask.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.slf4j.Marker; 6 | import org.slf4j.MarkerFactory; 7 | 8 | public class LoggingTask implements Runnable { 9 | 10 | static Marker HOWDY_MARKER = MarkerFactory.getMarker("HOWDY"); 11 | static Marker TOTO = MarkerFactory.getMarker("TOTO"); 12 | 13 | static { 14 | TOTO.add(HOWDY_MARKER); 15 | } 16 | Logger logger = LoggerFactory.getLogger(LoggingTask.class); 17 | 18 | String msg; 19 | 20 | int i = 0; 21 | 22 | LoggingTask(String msg) { 23 | this.msg = msg; 24 | } 25 | 26 | public void run() { 27 | if(i % 100 == 99) { 28 | logger.info(HOWDY_MARKER, msg + " - " + (i++), new Exception("e")); 29 | } else { 30 | logger.trace("x {]", i++); 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/webapp/logout.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> 5 | <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 6 | 7 | 8 | 9 | 10 | 11 | Logout 12 | 13 |

Logout

14 | <%@include file="includes/menu.jsp"%> 15 | 16 | <% 17 | String user = (String)request.getAttribute(Constants.USERID_SESSION_KEY); 18 | String display; 19 | if (user == null || user.trim().length() == 0) { 20 | display = "No user were connected"; 21 | } else { 22 | display = "User " + user + " was logged out successfully"; 23 | } 24 | %> 25 | 26 |
27 |

<%=display %>

28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /src/main/webapp/prime.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> 5 | <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 6 | 7 | 8 | 9 | 10 | Prime 11 | 12 |

Prime numbers

13 | <%@include file="includes/menu.jsp"%> 14 | 15 | 16 |
17 | 18 |

Please enter a number

19 | 20 | 21 | 22 |

23 | 24 |

Submit

25 |
26 | 27 |

The following numbers are divisible by 2 and a rather large prime, 400000066, 4000000000006

28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /src/main/webapp/includes/menu.jsp: -------------------------------------------------------------------------------- 1 | <%@page import="ch.qos.logback.demo.Constants"%> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/etc/parts/logback-access-image-filter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | String requestURL = event.getRequestURL().toString(); 5 | return requestURL.contains("/logback-demo/images/"); 6 | 7 | 8 | DENY 9 | NEUTRAL 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | fluffRegex 18 | (images|favicon.ico|/css/.*\.css) 19 | false 20 | 21 | 22 | String requestURL = event.getRequestURL().toString(); 23 | return fluffRegex.matches(requestURL); 24 | 25 | 26 | DENY 27 | NEUTRAL 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/Runner.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.util.concurrent.Executors; 7 | import java.util.concurrent.ScheduledExecutorService; 8 | import java.util.concurrent.TimeUnit; 9 | 10 | public class Runner { 11 | 12 | Logger logger = LoggerFactory.getLogger(Runner.class); 13 | ScheduledExecutorService scheduledExecutorService; 14 | 15 | Runner(String applicationNam) { 16 | scheduledExecutorService = Executors.newScheduledThreadPool(2); 17 | } 18 | 19 | public void start() { 20 | addTask(); 21 | } 22 | 23 | void addTask() { 24 | Runnable runnable = new LoggingTask("Howdydy-diddly-ho"); 25 | scheduledExecutorService.scheduleAtFixedRate(runnable, 26 | 0, 100, TimeUnit.MILLISECONDS); 27 | } 28 | 29 | public void stop() { 30 | scheduledExecutorService.shutdownNow(); 31 | scheduledExecutorService = null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/webapp/primeResults.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> 5 | <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 6 | <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> 7 | 8 | 9 | 10 | 11 | Prime Results 12 | 13 |

Prime Results

14 | <%@include file="includes/menu.jsp"%> 15 | 16 |
17 |

Number entered was: .

18 |

Results computed in ms.

19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/prime/PrimeForm.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.prime; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.apache.struts.action.ActionErrors; 6 | import org.apache.struts.action.ActionForm; 7 | import org.apache.struts.action.ActionMapping; 8 | import org.apache.struts.action.ActionMessage; 9 | 10 | 11 | public class PrimeForm extends ActionForm { 12 | 13 | private static final long serialVersionUID = 0L; 14 | 15 | Long number; 16 | 17 | public Long getNumber() { 18 | return number; 19 | } 20 | 21 | public void setNumber(Long number) { 22 | this.number = number; 23 | } 24 | 25 | public ActionErrors validate( 26 | ActionMapping mapping, HttpServletRequest request ) { 27 | ActionErrors errors = new ActionErrors(); 28 | 29 | if( getNumber() == null || ((getNumber().longValue()) != -1 && (getNumber().longValue() < 1))) { 30 | errors.add("number",new ActionMessage("errors.minNumber")); 31 | } 32 | 33 | return errors; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/resources/parts/logback-basic.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n 10 | 11 | 12 | 13 | 14 | 16 | logFile.log 17 | 19 | 20 | logFile.%d{yyyy-MM-dd_HH-mm}.log.zip 21 | 22 | 23 | 24 | 25 | 26 | %d{HH:mm:ss,SSS} [%thread] %-5level %logger{32} - %msg%n 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/lottery/LotteryForm.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.lottery; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.apache.struts.action.ActionErrors; 6 | import org.apache.struts.action.ActionForm; 7 | import org.apache.struts.action.ActionMapping; 8 | import org.apache.struts.action.ActionMessage; 9 | 10 | 11 | public class LotteryForm extends ActionForm { 12 | 13 | private static final long serialVersionUID = 0L; 14 | 15 | private Integer guessed_number; 16 | 17 | public Integer getGuessed_number() { 18 | return guessed_number; 19 | } 20 | 21 | public void setGuessed_number(Integer guessed_number) { 22 | this.guessed_number = guessed_number; 23 | } 24 | 25 | public ActionErrors validate( 26 | ActionMapping mapping, HttpServletRequest request ) { 27 | ActionErrors errors = new ActionErrors(); 28 | 29 | if( getGuessed_number() == null || getGuessed_number().intValue() < 1 ) { 30 | errors.add("number",new ActionMessage("errors.minNumber")); 31 | } 32 | return errors; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/webapp/login.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1" %> 3 | 4 | <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> 5 | <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> 6 | 7 | 8 | 9 | 10 | 11 | Login 12 | 13 | 14 |

Login

15 | <%@include file="includes/menu.jsp" %> 16 |
17 | 18 |

Welcome! Please enter your username to log in.

19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
username:
email:
33 | 34 |

Submit

35 |
36 | 37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/webapp/reload.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> 5 | <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 6 | <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%> 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Reload configuration

15 | <%@include file="includes/menu.jsp" %> 16 | 17 | 18 |
19 | 20 | 21 | 22 |

23 | <%=Constants.ACCESS %> 24 | <%=Constants.CLASSIC %> 25 | Reload

26 |
27 | 28 |

29 | 30 |

31 | Status of reloading: 32 |

33 | 34 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n 12 | 13 | 14 | 15 | 16 | 18 | logFile.log 19 | 21 | 22 | logFile.%d{yyyy-MM-dd_HH-mm}.log.zip 23 | 24 | 25 | 26 | 27 | 28 | %d{HH:mm:ss,SSS} [%thread] %-5level %logger{32} - %msg%n 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/login/LogoutAction.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.login; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.apache.struts.action.Action; 7 | import org.apache.struts.action.ActionForm; 8 | import org.apache.struts.action.ActionForward; 9 | import org.apache.struts.action.ActionMapping; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | import org.slf4j.MDC; 14 | import ch.qos.logback.demo.Constants; 15 | 16 | public class LogoutAction extends Action { 17 | 18 | Logger logger = LoggerFactory.getLogger(LogoutAction.class); 19 | 20 | public ActionForward execute(ActionMapping actionMapping, 21 | ActionForm actionForm, HttpServletRequest request, 22 | HttpServletResponse response) throws Exception { 23 | 24 | String username = (String)request.getSession().getAttribute(Constants.USERID_SESSION_KEY); 25 | 26 | MDC.remove(Constants.USERID_MDC_KEY); 27 | logger.info("User: " + username + " just logged out."); 28 | 29 | request.setAttribute(Constants.USERID_SESSION_KEY, username); 30 | request.getSession().removeAttribute(Constants.USERID_SESSION_KEY); 31 | 32 | return actionMapping.findForward("next"); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/resources/MessageResources.properties: -------------------------------------------------------------------------------- 1 | # -- standard errors -- 2 | errors.header=
    3 | errors.prefix=
  • 4 | errors.suffix=
  • 5 | errors.footer=
6 | 7 | 8 | ## -- PropertiesTranslator messages -- 9 | date.lastModified=25-09-2006 10 | 11 | 12 | ## -- validator -- 13 | errors.minNumber=Number must be 1 or greater. 14 | errors.username.invalid=The username {0} is invalid. 15 | errors.email.invalid=The email {0} is invalid. 16 | 17 | errors.invalid={0} is invalid. 18 | errors.maxlength={0} can not be greater than {1} characters. 19 | errors.minlength={0} can not be less than {1} characters. 20 | errors.range={0} is not in the range {1} through {2}. 21 | errors.required={0} is required. 22 | errors.byte={0} must be an byte. 23 | errors.date={0} is not a date. 24 | errors.double={0} must be an double. 25 | errors.float={0} must be an float. 26 | errors.integer={0} must be an integer. 27 | errors.long={0} must be an long. 28 | errors.short={0} must be an short. 29 | errors.creditcard={0} is not a valid credit card number. 30 | errors.email={0} is an invalid e-mail address. 31 | 32 | ## -- other -- 33 | errors.cancel=Operation cancelled. 34 | errors.detail={0} 35 | errors.general=The process did not complete. Details should follow. 36 | errors.token=Request could not be completed. Operation is not in sequence. 37 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/Constants.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo; 2 | 3 | public class Constants { 4 | 5 | public static final String MGMNT_DOMAIN = "qos"; 6 | public static final String USERID_SESSION_KEY = "userid"; 7 | public static final String USERID_MDC_KEY = "userid"; 8 | public static final String USERNAME_PROPERTY = "username"; 9 | 10 | public static final String EMAIL_PROPERTY = "email"; 11 | public static final String EMAIL_MDC_KEY = "email"; 12 | public static final String EMAIL_SESSION_KEY = "email"; 13 | 14 | public static final String SESSION_ID_MDC_KEY = "sessionId"; 15 | 16 | 17 | 18 | 19 | public static final String GUESSED_NUMBER = "guessed_number"; 20 | public static final Integer WINNING_NUMBER = new Integer(99); 21 | 22 | public static final String CYCLIC_BUFFER_APPENDER_NAME = "CYCLIC"; 23 | 24 | public static final String PRIME_NUMBER = "number"; 25 | public static final String PRIME_DURATION = "duration"; 26 | public static final String PRIME_RESULTS = "prime_results"; 27 | 28 | public static final String REQUESTLOG_NAME = "LogbackRequestLog"; 29 | 30 | public static final String ACCESS = "Access"; 31 | public static final String CLASSIC = "Classic"; 32 | public static final String CONTEXT_LIST = "ContextList"; 33 | 34 | public static final String STATUS = "Status"; 35 | 36 | public static final String RELOAD_RESULT = "reload_result"; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/login/LoginForm.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.login; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.apache.struts.action.ActionErrors; 6 | import org.apache.struts.action.ActionForm; 7 | import org.apache.struts.action.ActionMapping; 8 | import org.apache.struts.action.ActionMessage; 9 | 10 | 11 | public class LoginForm extends ActionForm { 12 | 13 | private static final long serialVersionUID = 0L; 14 | 15 | private String username; 16 | private String email; 17 | 18 | public String getEmail() { 19 | return email; 20 | } 21 | 22 | public void setEmail(String email) { 23 | this.email = email; 24 | } 25 | 26 | public String getUsername() { 27 | return username; 28 | } 29 | 30 | public void setUsername(String username) { 31 | this.username = username; 32 | } 33 | 34 | 35 | public ActionErrors validate ( 36 | ActionMapping mapping, HttpServletRequest request ) { 37 | ActionErrors errors = new ActionErrors(); 38 | 39 | if( getUsername() == null || getUsername().trim().length() == 0 ) { 40 | errors.add("username",new ActionMessage("errors.username.invalid", getUsername())); 41 | } 42 | if( getEmail() == null || getEmail().trim().length() == 0 ) { 43 | errors.add("email",new ActionMessage("errors.email.invalid", getUsername())); 44 | } 45 | return errors; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/lottery/LotteryAction.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.lottery; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.apache.struts.action.Action; 7 | import org.apache.struts.action.ActionForm; 8 | import org.apache.struts.action.ActionForward; 9 | import org.apache.struts.action.ActionMapping; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | import ch.qos.logback.demo.Constants; 14 | 15 | public class LotteryAction extends Action { 16 | 17 | Logger logger = LoggerFactory.getLogger(LotteryAction.class); 18 | 19 | public ActionForward execute(ActionMapping actionMapping, 20 | ActionForm actionForm, HttpServletRequest request, 21 | HttpServletResponse response) throws Exception { 22 | 23 | if (actionForm != null) { 24 | LotteryForm form = (LotteryForm) actionForm; 25 | 26 | Integer guessedNumber = form.getGuessed_number(); 27 | 28 | logger.info("Number: " + guessedNumber + " was tried."); 29 | if (guessedNumber.equals(Constants.WINNING_NUMBER)) { 30 | logger.info("The Grand Prize was won!"); 31 | return actionMapping.findForward("win"); 32 | } else { 33 | request.setAttribute(Constants.GUESSED_NUMBER, guessedNumber); 34 | return actionMapping.findForward("loose"); 35 | } 36 | } 37 | 38 | return actionMapping.findForward("loose"); 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/login/LoginAction.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.login; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.apache.struts.action.Action; 7 | import org.apache.struts.action.ActionForm; 8 | import org.apache.struts.action.ActionForward; 9 | import org.apache.struts.action.ActionMapping; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | import org.slf4j.MDC; 14 | import ch.qos.logback.demo.Constants; 15 | 16 | public class LoginAction extends Action { 17 | 18 | Logger logger = LoggerFactory.getLogger(LoginAction.class); 19 | 20 | public ActionForward execute(ActionMapping actionMapping, 21 | ActionForm actionForm, HttpServletRequest request, 22 | HttpServletResponse response) throws Exception { 23 | 24 | if (actionForm != null) { 25 | LoginForm form = (LoginForm) actionForm; 26 | 27 | String username = form.getUsername(); 28 | String email = form.getEmail(); 29 | 30 | if (username != null) { 31 | MDC.put(Constants.USERID_MDC_KEY, username); 32 | MDC.put(Constants.EMAIL_MDC_KEY, email); 33 | logger.info("Login: user {} with email {} just logged in.", username, email); 34 | request.getSession().setAttribute(Constants.USERID_SESSION_KEY, username); 35 | request.getSession().setAttribute(Constants.EMAIL_SESSION_KEY, email); 36 | } 37 | } 38 | 39 | return actionMapping.findForward("next"); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tiles-defs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/main/webapp/viewStatii.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> 5 | <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 6 | <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> 7 | 8 | 9 | 10 | 15 | 16 | 17 |

Statii

18 | <%@include file="includes/mini-menu.jsp" %> 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | <%=Constants.ACCESS %> 27 | <%=Constants.CLASSIC %> 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Display 38 | 39 | 40 |
41 | 42 |
43 | 44 | 45 |
46 | 
47 | 
48 |
49 | 50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/ContextListener.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo; 2 | 3 | import java.lang.management.ManagementFactory; 4 | 5 | import javax.management.MBeanServer; 6 | import javax.servlet.ServletContext; 7 | import javax.servlet.ServletContextEvent; 8 | import javax.servlet.ServletContextListener; 9 | 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | public class ContextListener implements ServletContextListener { 14 | 15 | static public final String TEST_GROUP = "TEST_GROUP"; 16 | 17 | Logger logger = LoggerFactory.getLogger(ContextListener.class); 18 | 19 | Runner runner; 20 | String servletContextName; 21 | 22 | public ContextListener() { 23 | } 24 | 25 | public void contextInitialized(ServletContextEvent sce) { 26 | ClassLoader ctcc = Thread.currentThread().getContextClassLoader(); 27 | logger.debug("Classload hashcode is " + ctcc.hashCode()); 28 | 29 | ServletContext servletContext = sce.getServletContext(); 30 | servletContextName = servletContext.getServletContextName(); 31 | logger 32 | .debug("Initializing for ServletContext [" + servletContextName + "]"); 33 | runner = new Runner(servletContextName); 34 | 35 | try { 36 | runner.start(); 37 | } catch (Exception e) { 38 | logger.error("Failed to configure Logback Demo", e); 39 | } 40 | 41 | } 42 | 43 | public void contextDestroyed(ServletContextEvent arg0) { 44 | logger.debug("Shutting down ServletContext [" + servletContextName + "]"); 45 | 46 | ClassLoader ctcc = Thread.currentThread().getContextClassLoader(); 47 | logger.debug("Classload hashcode is " + ctcc.hashCode()); 48 | 49 | if (runner != null) { 50 | runner.stop(); 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/statii/ChooseContextAction.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.statii; 2 | 3 | import java.util.List; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | import ch.qos.logback.classic.util.ContextSelectorStaticBinder; 9 | import org.apache.struts.action.Action; 10 | import org.apache.struts.action.ActionForm; 11 | import org.apache.struts.action.ActionForward; 12 | import org.apache.struts.action.ActionMapping; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | import ch.qos.logback.classic.LoggerContext; 17 | import ch.qos.logback.demo.Constants; 18 | import ch.qos.logback.demo.util.EnhancedStatusPrinter; 19 | 20 | public class ChooseContextAction extends Action { 21 | 22 | Logger logger = LoggerFactory.getLogger(ChooseModuleAction.class); 23 | 24 | public ActionForward execute(ActionMapping actionMapping, 25 | ActionForm actionForm, HttpServletRequest request, 26 | HttpServletResponse response) throws Exception { 27 | 28 | StringBuffer buf = new StringBuffer(); 29 | 30 | if (actionForm != null) { 31 | ChooseContextForm form = (ChooseContextForm) actionForm; 32 | 33 | String contextName = form.getContextName(); 34 | LoggerContext context = ContextSelectorStaticBinder.getSingleton().getContextSelector().getLoggerContext(contextName); 35 | EnhancedStatusPrinter.print(buf, context.getStatusManager()); 36 | request.setAttribute(Constants.STATUS, buf.toString()); 37 | } 38 | 39 | List contextNames = ContextSelectorStaticBinder.getSingleton().getContextSelector().getContextNames(); 40 | request.setAttribute(Constants.CONTEXT_LIST, contextNames); 41 | 42 | return actionMapping.findForward("next"); 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/UserServletFilter.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo; 2 | 3 | import java.io.IOException; 4 | import java.security.Principal; 5 | 6 | import javax.servlet.Filter; 7 | import javax.servlet.FilterChain; 8 | import javax.servlet.FilterConfig; 9 | import javax.servlet.ServletException; 10 | import javax.servlet.ServletRequest; 11 | import javax.servlet.ServletResponse; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpSession; 14 | 15 | import org.slf4j.MDC; 16 | 17 | public class UserServletFilter implements Filter { 18 | 19 | boolean userRegistered = false; 20 | 21 | public void destroy() { 22 | } 23 | 24 | public void doFilter(ServletRequest request, ServletResponse response, 25 | FilterChain chain) throws IOException, ServletException { 26 | 27 | HttpServletRequest req = (HttpServletRequest) request; 28 | Principal principal = req.getUserPrincipal(); 29 | // Please note that we could have also used a cookie to 30 | // retrieve the user name 31 | 32 | HttpSession session = req.getSession(); 33 | MDC.put("sessionId", session.getId()); 34 | updateMDCValues(session); 35 | 36 | try { 37 | // invoke subsequent filters 38 | chain.doFilter(request, response); 39 | } finally { 40 | // always clear the MDC at the end of the request 41 | MDC.clear(); 42 | } 43 | } 44 | 45 | public void init(FilterConfig arg0) throws ServletException { 46 | } 47 | 48 | private void updateMDCValues(HttpSession session) { 49 | updateMDCSingleValue(session, Constants.USERID_SESSION_KEY, Constants.USERID_MDC_KEY); 50 | updateMDCSingleValue(session, Constants.EMAIL_SESSION_KEY, Constants.EMAIL_MDC_KEY); 51 | } 52 | 53 | private void updateMDCSingleValue(HttpSession session, String sessionKey, String mdcKey) { 54 | String val = (String)session.getAttribute(sessionKey); 55 | MDC.put(mdcKey, val); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/prime/PrimeAction.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.prime; 2 | 3 | import ch.qos.logback.demo.Constants; 4 | import org.apache.struts.action.Action; 5 | import org.apache.struts.action.ActionForm; 6 | import org.apache.struts.action.ActionForward; 7 | import org.apache.struts.action.ActionMapping; 8 | import org.slf4j.*; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import static ch.qos.logback.classic.ClassicConstants.FINALIZE_SESSION_MARKER; 13 | 14 | public class PrimeAction extends Action { 15 | 16 | Logger logger = LoggerFactory.getLogger(PrimeAction.class); 17 | static Marker SMTP_TRIGGER = MarkerFactory.getMarker("SMTP_TRIGGER"); 18 | static { 19 | // markers can hold references to other markers 20 | SMTP_TRIGGER.add(FINALIZE_SESSION_MARKER); 21 | } 22 | 23 | public ActionForward execute(ActionMapping actionMapping, 24 | ActionForm actionForm, HttpServletRequest request, 25 | HttpServletResponse response) throws Exception { 26 | 27 | PrimeForm form = (PrimeForm) actionForm; 28 | 29 | 30 | Long number = form.getNumber(); 31 | MDC.put("txId", String.valueOf(number)); 32 | 33 | if (number == 99) { 34 | logger.info("99 is a magical value", new Exception("99 is supposedly invalid")); 35 | } 36 | 37 | try { 38 | NumberCruncher nc = new NumberCruncherImpl(); 39 | Long start = System.currentTimeMillis(); 40 | Long[] result = nc.factor(number); 41 | Long duration = System.currentTimeMillis() - start; 42 | logger.info("Results computed in {} ms", duration); 43 | 44 | request.setAttribute(Constants.PRIME_NUMBER, number); 45 | request.setAttribute(Constants.PRIME_DURATION, duration); 46 | request.setAttribute(Constants.PRIME_RESULTS, result); 47 | return actionMapping.findForward("next"); 48 | } finally { 49 | logger.info(SMTP_TRIGGER, "Prime computation ended"); 50 | MDC.put("txId", null); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/util/HTMLUtil.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.util; 2 | 3 | import java.io.PrintWriter; 4 | 5 | public class HTMLUtil { 6 | 7 | public static void printMenu(String localRef, PrintWriter output) { 8 | output.append(""); 9 | output.append(""); 11 | output.append(""); 13 | output.append(""); 15 | output.append(""); 17 | output.append(""); 19 | output.append(""); 21 | output.append(""); 23 | output.append(""); 25 | output.append("
Home
Login
View Statii
View logs
Prime number
Play the loto
Reload config
logout
"); 26 | } 27 | 28 | public static void printHome(String localRef, PrintWriter output) { 29 | output.append("
Main page
\r\n"); 32 | } 33 | 34 | public static void printContentStart(PrintWriter output) { 35 | output.append("
"); 36 | } 37 | 38 | public static void printContentEnd(PrintWriter output) { 39 | output.append("
"); 40 | } 41 | 42 | public static void printCSSLink(String localRef, PrintWriter output) { 43 | output.append(""); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 4 | <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%> 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Logback demo center

14 | <%@include file="includes/menu.jsp" %> 15 | 16 |
17 | 18 | 19 |

20 | Hi there, ! 21 |

22 |
23 |

24 | Welcome to the logback demo. 25 |

26 |

27 | The Login page lets you enter a username, which will be associated to the 28 | session. This can be used to test the filter functionnalities of logback. 29 | To tweak logback classic's configuration, modify the /src/resources/logback.xml file. 30 |

31 |

32 | The ViewStatii page lets you view the logback statuses. Status objects are logback's internal 33 | error reporting components. Viewing them allows you to see if logback's initialization has gone wrong, or 34 | verify that your configuration of logback behaves like you expect it to. 35 |

36 |

37 | View logs is a page that shows the last 512 events that were reported to logback classic. 38 | This number is configurable in the previously mentionned configuration file. The View logs page 39 | uses HTMLLayout to format the events in a easily readable manner. 40 |

41 |

42 | Play the lottery will allow you to enter a number and maybe win the logback's Grand Prize. 43 | Each time somebody enters the winning number, logback access catches the request url and 44 | sends an email according to its configuration file, /src/etc/logback-access.xml. 45 |

46 |

47 | The Prime number page lets you enter any number, and let the webapp search for its divisors. 48 |

49 |

50 | Use Reload config to reset logback and read again its configuration file, enabling 51 | your modifications. 52 |

53 |
54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/statii/ChooseModuleAction.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.statii; 2 | 3 | import java.util.List; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | import ch.qos.logback.classic.util.ContextSelectorStaticBinder; 9 | import org.apache.struts.action.Action; 10 | import org.apache.struts.action.ActionForm; 11 | import org.apache.struts.action.ActionForward; 12 | import org.apache.struts.action.ActionMapping; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | import ch.qos.logback.access.jetty.RequestLogImpl; 17 | import ch.qos.logback.access.jetty.RequestLogRegistry; 18 | import ch.qos.logback.demo.Constants; 19 | import ch.qos.logback.demo.util.EnhancedStatusPrinter; 20 | 21 | public class ChooseModuleAction extends Action { 22 | 23 | Logger logger = LoggerFactory.getLogger(ChooseModuleAction.class); 24 | 25 | public ActionForward execute(ActionMapping actionMapping, 26 | ActionForm actionForm, HttpServletRequest request, 27 | HttpServletResponse response) throws Exception { 28 | 29 | StringBuffer buf = new StringBuffer(); 30 | 31 | if (actionForm != null) { 32 | ChooseModuleForm form = (ChooseModuleForm) actionForm; 33 | 34 | String sm = form.getModuleName(); 35 | if (sm != null && sm.equals(Constants.ACCESS)) { 36 | // try { 37 | RequestLogImpl requestLog = RequestLogRegistry.get(Constants.REQUESTLOG_NAME); 38 | if (requestLog != null) { 39 | EnhancedStatusPrinter.print(buf, requestLog.getStatusManager()); 40 | } else { 41 | buf.append("Could not get " + Constants.REQUESTLOG_NAME); 42 | } 43 | // } catch(NoClassDefFoundError error) { 44 | // //in case the RequestLogRegistry is not available 45 | // buf.append("Could not get " + Constants.REQUESTLOG_NAME); 46 | // } 47 | 48 | request.setAttribute(Constants.STATUS, buf.toString()); 49 | 50 | } else { 51 | List contextNames = ContextSelectorStaticBinder.getSingleton().getContextSelector().getContextNames(); 52 | request.setAttribute(Constants.CONTEXT_LIST, contextNames); 53 | } 54 | } 55 | 56 | return actionMapping.findForward("next"); 57 | } 58 | } -------------------------------------------------------------------------------- /src/etc/parts/jetty-jmx.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 8082 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/etc/parts/logback-access-FULL.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | countingFilter 5 | 6 | 7 | 9 | 10 | 11 | 12 | url.matches(event.getRequestURL().toString()) 13 | 14 | 15 | lottery.do 16 | false 17 | 18 | 19 | ACCEPT 20 | DENY 21 | 22 | 23 | 24 | LOTTERY: %A [%r] Guess=%reqParameter{guessed_number} 25 | 26 | 27 | 28 | 29 | 31 | 32 | %h %l %u %t \"%r\" %s %b 33 | 34 | 35 | 36 | 43 | 44 | 46 | 47 | %h%l%u%t%r%s%b 48 | 49 | 50 | 51 | winner.jsp 52 | 53 | ceki@qos.ch 54 | mail.qos.ch 55 | 56 | 61 | 62 | Winner detected 63 | 71 | sebastien@qos.ch 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/validation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 31 | 32 | 33 | 36 | 37 | 38 | mask 39 | ^[0-9a-zA-Z]*$ 40 | 41 | 42 |
43 | 44 |
45 | 46 | 47 | 48 | 49 | 50 | postalCode 51 | ^[0-9a-zA-Z]*$ 52 | 53 | 54 | 55 |
56 | 59 | 60 | 61 | 64 | 65 | 66 | mask 67 | ^[0-9a-zA-Z]*$ 68 | 69 | 70 |
71 | 72 |
73 | 74 |
75 | -------------------------------------------------------------------------------- /src/main/webapp/css/pk.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin-top: 10px; 3 | margin-left: 10px; 4 | font-size: large; 5 | background-image: url(../images/lblogo.jpg); 6 | background-repeat: no-repeat; 7 | background-position: left top; 8 | } 9 | 10 | h2 { 11 | text-align: center; 12 | margin-top: 1em; 13 | } 14 | 15 | table { 16 | margin-left: 2em; 17 | margin-right: 2em; 18 | /*border-left: 2px solid #AAA; 19 | border-right: 2px solid #AAA;*/ 20 | } 21 | 22 | div.content { 23 | margin-top: 80px; 24 | margin-left: 220px; 25 | } 26 | 27 | div.content_full { 28 | margin-top: 80px; 29 | margin-left: 10px; 30 | } 31 | 32 | div.statiiMenus { 33 | width: 300px; 34 | /*float: right;*/ 35 | display: block; 36 | padding-top: 40px; 37 | padding-left: 20ex; 38 | padding-right: 1ex; 39 | margin-left: 3em; 40 | margin-right: 3em; 41 | } 42 | 43 | table.nav { 44 | margin-top: 40px; 45 | width: 10em; 46 | float: left; 47 | overflow: auto; 48 | } 49 | 50 | TR.even { 51 | background: #FFFFFF; 52 | } 53 | 54 | TR.odd { 55 | background: #EAEAEA; 56 | } 57 | 58 | TR.error { 59 | font-weight: bold; 60 | color: #FF4040 61 | } 62 | 63 | TD { 64 | padding-right: 1ex; 65 | padding-left: 1ex; 66 | padding-top: 0ex; 67 | /*border-right: 2px solid #AAA;*/ 68 | } 69 | 70 | TD.Date { 71 | text-align: right; 72 | font-family: courier, monospace; 73 | font-size: smaller; 74 | } 75 | 76 | TD.Thread { 77 | text-align: left; 78 | } 79 | 80 | TD.Level { 81 | text-align: right; 82 | } 83 | 84 | TD.Logger { 85 | text-align: left; 86 | } 87 | 88 | TR.header { 89 | background: #596ED5; 90 | color: #FFF; 91 | font-weight: bold; 92 | font-size: larger; 93 | } 94 | 95 | TD.Exception { 96 | background: #A2AEE8; 97 | font-family: courier, monospace; 98 | } 99 | 100 | TD.sexy { 101 | border-top: 2px solid #DDD; 102 | border-left: 2px solid #DDD; 103 | border-right: 2px solid #888; 104 | border-bottom: 2px solid #888; 105 | } 106 | 107 | .red { 108 | color: #CC0000; 109 | } 110 | 111 | .orange { 112 | color: #FF6600; 113 | } 114 | 115 | A.sexy,INPUT.sexy,span.sexy { /*background: #FFF; */ 116 | color: #0079C5; 117 | font-weight: bold; 118 | font-family: "Comic Sans MS", sans-serif; 119 | font-size: 14px; 120 | white-space: nowrap; 121 | padding: 0px 1em 0px 1em; 122 | margin: 5px 0px 3px 0px; 123 | text-decoration: none; 124 | } 125 | 126 | TD.sexy:hover,A.sexy:hover,INPUT.sexy:hover,INPUT.sexy_hover,span.sexy:hover 127 | { 128 | background: #E0E0EF; 129 | } -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/util/EnhancedStatusPrinter.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.util; 2 | 3 | import java.io.PrintWriter; 4 | import java.io.StringWriter; 5 | import java.text.SimpleDateFormat; 6 | import java.util.Iterator; 7 | import java.util.List; 8 | 9 | import ch.qos.logback.classic.pattern.TargetLengthBasedClassNameAbbreviator; 10 | import ch.qos.logback.core.status.Status; 11 | import ch.qos.logback.core.status.StatusManager; 12 | 13 | public class EnhancedStatusPrinter { 14 | 15 | private static final int ABBR_LENGTH = 17; 16 | private static TargetLengthBasedClassNameAbbreviator abbreviator = new TargetLengthBasedClassNameAbbreviator(ABBR_LENGTH); 17 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd'T'HH:mm:ss"); 18 | 19 | public static String print(Status s) { 20 | StringBuffer buf = new StringBuffer(); 21 | buf.append(sdf.format(s.getDate()) + " "); 22 | switch (s.getEffectiveLevel()) { 23 | case Status.INFO: 24 | buf.append("INFO"); 25 | break; 26 | case Status.WARN: 27 | buf.append("WARN"); 28 | break; 29 | case Status.ERROR: 30 | buf.append("ERROR"); 31 | break; 32 | } 33 | if (s.getOrigin() != null) { 34 | buf.append(" in "); 35 | buf.append(abbreviator.abbreviate(s.getOrigin().getClass().getName())); 36 | buf.append(" -"); 37 | } 38 | 39 | buf.append(" "); 40 | buf.append(s.getMessage()); 41 | 42 | if (s.getThrowable() != null) { 43 | buf.append(" "); 44 | buf.append(s.getThrowable()); 45 | } 46 | 47 | return buf.toString(); 48 | } 49 | 50 | public static void print(StringBuffer buf, StatusManager sm) { 51 | 52 | List statusList = sm.getCopyOfStatusList(); 53 | for (Status s: statusList) { 54 | print(buf, "", s); 55 | } 56 | } 57 | 58 | public static void print(StringBuffer buf, String indentation, Status s) { 59 | String prefix; 60 | if(s.hasChildren()) { 61 | prefix = indentation + "+ "; 62 | } else { 63 | prefix = indentation + "|-"; 64 | } 65 | buf.append(prefix); 66 | buf.append(EnhancedStatusPrinter.print(s)); 67 | buf.append("\r\n"); 68 | 69 | StringWriter sw = new StringWriter(); 70 | PrintWriter pw = new PrintWriter(sw); 71 | if (s.getThrowable() != null) { 72 | s.getThrowable().printStackTrace(pw); 73 | buf.append(sw.getBuffer()); 74 | } 75 | if(s.hasChildren()) { 76 | Iterator ite = s.iterator(); 77 | while(ite.hasNext()) { 78 | Status child = ite.next(); 79 | print(buf, indentation+" ", child); 80 | } 81 | } 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/prime/NumberCruncherImpl.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.prime; 2 | 3 | import java.rmi.RemoteException; 4 | import java.util.Vector; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | 10 | /** 11 | * A simple NumberCruncher implementation that logs its progress when 12 | * factoring numbers. The purpose of the whole exercise is to show the 13 | * use of mapped diagnostic contexts in order to distinguish the log 14 | * output from different client requests. 15 | * */ 16 | public class NumberCruncherImpl implements NumberCruncher { 17 | static Logger logger = LoggerFactory.getLogger(NumberCruncherImpl.class); 18 | 19 | private static int MAX_COUNT_BEFORE_WARN = 1000000; 20 | 21 | public NumberCruncherImpl() throws RemoteException { 22 | } 23 | 24 | public Long[] factor(long number) throws RemoteException { 25 | 26 | // The information contained within the request is another source 27 | // of distinctive information. It might reveal the users name, 28 | // date of request, request ID etc. In servlet type environments, 29 | // useful information is contained in the HttpRequest or in the 30 | // HttpSession. 31 | //MDC.put("number", new Integer(number)); 32 | 33 | logger.info("Beginning to factor."); 34 | 35 | if (number <= 0) { 36 | IllegalArgumentException e = new IllegalArgumentException(number + 37 | " is not a positive integer."); 38 | logger.error("Bad argument", e); 39 | //throw e; 40 | return new Long[] { 0L }; 41 | } else if (number == 1) { 42 | return new Long[] { 1L }; 43 | } 44 | 45 | Vector factors = new Vector(); 46 | long n = number; 47 | int count = 0; 48 | for (long i = 2; (i <= n) && ((i * i) <= number); i++) { 49 | // It is bad practice to place log requests within tight loops. 50 | // It is done here to show interleaved log output from 51 | // different requests. 52 | 53 | if (count++ >= MAX_COUNT_BEFORE_WARN) { 54 | logger.warn("Already tried " + MAX_COUNT_BEFORE_WARN + " factors."); 55 | count = 0; 56 | } 57 | //logger.debug("Trying "+i+" as a factor."); 58 | logger.debug("Trying {} as a factor.", i); 59 | 60 | if ((n % i) == 0) { 61 | logger.info("Found factor " + i); 62 | factors.addElement(i); 63 | 64 | do { 65 | n /= i; 66 | } while ((n % i) == 0); 67 | } 68 | 69 | // Placing artificial delays in tight-loops will also lead to 70 | // sub-optimal resuts. :-) 71 | // delay(100); 72 | } 73 | 74 | if (n != 1) { 75 | logger.info("Found factor " + n); 76 | factors.addElement(n); 77 | } 78 | 79 | int len = factors.size(); 80 | 81 | Long[] result = new Long[len]; 82 | 83 | for (int i = 0; i < len; i++) { 84 | result[i] = factors.elementAt(i).longValue(); 85 | } 86 | 87 | return result; 88 | 89 | } 90 | 91 | 92 | public static void delay(int millis) { 93 | try { 94 | Thread.sleep(millis); 95 | } catch (InterruptedException e) { 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/reload/ReloadConfigAction.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo.reload; 2 | 3 | import java.net.URL; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | import org.apache.struts.action.Action; 9 | import org.apache.struts.action.ActionForm; 10 | import org.apache.struts.action.ActionForward; 11 | import org.apache.struts.action.ActionMapping; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | 15 | import ch.qos.logback.access.jetty.RequestLogImpl; 16 | import ch.qos.logback.access.jetty.RequestLogRegistry; 17 | import ch.qos.logback.classic.LoggerContext; 18 | import ch.qos.logback.classic.joran.JoranConfigurator; 19 | import ch.qos.logback.core.joran.spi.JoranException; 20 | import ch.qos.logback.core.util.Loader; 21 | import ch.qos.logback.demo.Constants; 22 | 23 | public class ReloadConfigAction extends Action { 24 | 25 | final public static String CLASSIC_FILE = "logback.xml"; 26 | 27 | Logger logger = LoggerFactory.getLogger(ReloadConfigAction.class); 28 | 29 | public ActionForward execute(ActionMapping actionMapping, 30 | ActionForm actionForm, HttpServletRequest request, 31 | HttpServletResponse response) throws Exception { 32 | 33 | boolean reload_successfull = false; 34 | 35 | if (actionForm != null) { 36 | ReloadConfigForm form = (ReloadConfigForm) actionForm; 37 | 38 | String moduleName = form.getModuleName(); 39 | if (moduleName != null && moduleName.equals(Constants.ACCESS)) { 40 | logger.debug("Reloading access module"); 41 | reload_successfull = reloadAccessConfiguration(); 42 | } else { 43 | logger.debug("Reloading classic module"); 44 | reload_successfull = reloadClassicConfiguration(); 45 | } 46 | } 47 | 48 | if (reload_successfull) { 49 | request.setAttribute(Constants.RELOAD_RESULT, "Success"); 50 | } else { 51 | request.setAttribute(Constants.RELOAD_RESULT, "Failure"); 52 | } 53 | 54 | return actionMapping.findForward("next"); 55 | } 56 | 57 | private boolean reloadClassicConfiguration() { 58 | try { 59 | LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory(); 60 | URL url = Loader.getResource(CLASSIC_FILE, Loader.getTCL()); 61 | if (url != null) { 62 | logger.debug("Found ressource at: " + url.getFile()); 63 | JoranConfigurator configurator = new JoranConfigurator(); 64 | configurator.setContext(lc); 65 | logger.info("Shutting down active logging configuration."); 66 | 67 | lc.reset(); 68 | configurator.doConfigure(url); 69 | lc.start(); 70 | logger.info("Now using new configuration."); 71 | return true; 72 | } else { 73 | //error no config file found 74 | return false; 75 | } 76 | } catch (JoranException je) { 77 | je.printStackTrace(); 78 | return false; 79 | } 80 | } 81 | 82 | private boolean reloadAccessConfiguration() { 83 | RequestLogImpl requestLog = RequestLogRegistry.get(Constants.REQUESTLOG_NAME); 84 | requestLog.stop(); 85 | requestLog.start(); 86 | if (requestLog.isStarted()) { 87 | return true; 88 | } 89 | return false; 90 | } 91 | 92 | } -------------------------------------------------------------------------------- /src/etc/jetty.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 10 27 | 200 28 | false 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 300000 42 | 2 43 | false 44 | 8443 45 | 20000 46 | 5000 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | src/etc/logback-access.xml 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | true 87 | true 88 | true 89 | 1000 90 | false 91 | false 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /src/main/java/ch/qos/logback/demo/ViewLastLog.java: -------------------------------------------------------------------------------- 1 | package ch.qos.logback.demo; 2 | 3 | import static ch.qos.logback.demo.Constants.CYCLIC_BUFFER_APPENDER_NAME; 4 | 5 | import java.io.IOException; 6 | import java.io.PrintWriter; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | import ch.qos.logback.classic.LoggerContext; 17 | import ch.qos.logback.classic.html.HTMLLayout; 18 | import ch.qos.logback.classic.html.UrlCssBuilder; 19 | import ch.qos.logback.classic.spi.ILoggingEvent; 20 | import ch.qos.logback.classic.spi.LoggingEvent; 21 | import ch.qos.logback.core.read.CyclicBufferAppender; 22 | 23 | public class ViewLastLog extends HttpServlet { 24 | 25 | private static final long serialVersionUID = -3551928133801157219L; 26 | 27 | Logger logger = LoggerFactory.getLogger(ViewLastLog.class); 28 | 29 | CyclicBufferAppender cyclicBufferAppender; 30 | HTMLLayout layout; 31 | static String PATTERN = "%d%thread%level%logger{25}%mdc{" 32 | + Constants.USERID_MDC_KEY + "}%msg"; 33 | 34 | @Override 35 | public void init() throws ServletException { 36 | LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); 37 | initialize(lc); 38 | super.init(); 39 | } 40 | 41 | void reacquireCBA() { 42 | LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); 43 | cyclicBufferAppender = (CyclicBufferAppender) context.getLogger( 44 | Logger.ROOT_LOGGER_NAME).getAppender(CYCLIC_BUFFER_APPENDER_NAME); 45 | } 46 | 47 | protected void service(HttpServletRequest req, HttpServletResponse resp) 48 | throws ServletException, IOException { 49 | 50 | reacquireCBA(); 51 | 52 | resp.setContentType("text/html"); 53 | PrintWriter output = resp.getWriter(); 54 | 55 | output.append(layout.getFileHeader()); 56 | String localRef = req.getContextPath(); 57 | output.append("

Last logging events

"); 58 | output.append(""); 59 | output.append(""); 61 | output 62 | .append(""); 63 | output.append("
Main Page
Jump to bottom
"); 64 | 65 | output.append("
"); 66 | output.append(layout.getPresentationHeader()); 67 | 68 | printLogs(output); 69 | 70 | output.append(layout.getPresentationFooter()); 71 | 72 | output.append(""); 73 | 74 | output.append("
"); 75 | 76 | output.append(layout.getFileFooter()); 77 | 78 | output.flush(); 79 | output.close(); 80 | } 81 | 82 | private void printLogs(PrintWriter output) { 83 | int count = -1; 84 | if (cyclicBufferAppender != null) { 85 | count = cyclicBufferAppender.getLength(); 86 | } 87 | 88 | if (count == -1) { 89 | output.append("Failed to locate CyclicBuffer\r\n"); 90 | } else if (count == 0) { 91 | output.append("No logging events to display\r\n"); 92 | } else { 93 | LoggingEvent le; 94 | for (int i = 0; i < count; i++) { 95 | le = (LoggingEvent) cyclicBufferAppender.get(i); 96 | output.append(layout.doLayout(le) + "\r\n"); 97 | } 98 | } 99 | } 100 | 101 | private void initialize(LoggerContext context) { 102 | logger.debug("Initializing ViewLastLog Servlet"); 103 | cyclicBufferAppender = (CyclicBufferAppender) context.getLogger( 104 | Logger.ROOT_LOGGER_NAME).getAppender(CYCLIC_BUFFER_APPENDER_NAME); 105 | 106 | layout = new HTMLLayout(); 107 | layout.setContext(context); 108 | UrlCssBuilder cssBuilder = new UrlCssBuilder(); 109 | cssBuilder.setUrl("../css/pk.css"); 110 | layout.setCssBuilder(cssBuilder); 111 | layout.setPattern(PATTERN); 112 | layout.setTitle("Last Logging Events"); 113 | layout.start(); 114 | } 115 | 116 | public boolean isResetResistant() { 117 | return false; 118 | } 119 | 120 | public void onStop(LoggerContext arg0) { 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | logback-demo 4 | 5 | 4.0.0 6 | ch.qos.logback 7 | logback-demo 8 | war 9 | 1.0 10 | 11 | 12 | 1.0.7 13 | 14 | 15 | 16 | 17 | struts 18 | struts 19 | 1.2.9 20 | compile 21 | 22 | 23 | 24 | commons-logging 25 | commons-logging 26 | 1.1.1 27 | 28 | 29 | 30 | 31 | javax.servlet 32 | servlet-api 33 | 2.4 34 | provided 35 | 36 | 37 | 38 | ch.qos.logback 39 | logback-core 40 | ${lb.version} 41 | provided 42 | 43 | 44 | ch.qos.logback 45 | logback-classic 46 | ${lb.version} 47 | 48 | 49 | ch.qos.logback 50 | logback-access 51 | ${lb.version} 52 | provided 53 | 54 | 55 | 56 | janino 57 | janino 58 | 2.4.3 59 | 60 | 61 | 62 | org.eclipse.jetty 63 | jetty-server 64 | 9.3.7.v20160115 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.apache.maven.plugins 72 | maven-war-plugin 73 | 2.0.1 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | org.mortbay.jetty 82 | jetty-maven-plugin 83 | 84 | 7.5.1.v20110908 85 | 86 | 0 87 | ${basedir}/src/etc/jetty.xml 88 | 89 | 90 | xxjetty.home 91 | ${basedir}/src/ 92 | 93 | 94 | 95 | 96 | 97 | ch.qos.logback 98 | logback-access 99 | ${lb.version} 100 | 101 | 102 | ch.qos.logback 103 | logback-core 104 | ${lb.version} 105 | 106 | 107 | janino 108 | janino 109 | 2.4.3 110 | 111 | 112 | 113 | mx4j 114 | mx4j-tools 115 | 3.0.1 116 | 117 | 118 | 119 | 120 | 121 | 122 | org.apache.maven.plugins 123 | maven-compiler-plugin 124 | 125 | 1.5 126 | 1.5 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | org.apache.maven.plugins 136 | maven-site-plugin 137 | 138 | 139 | 140 | 141 | 142 | org.apache.maven.plugins 143 | maven-jxr-plugin 144 | 145 | true 146 | target/site/apidocs/ 147 | true 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | pixie 156 | scp://pixie.qos.ch/var/www/logback-demo.qos.ch/htdocs/ 157 | 158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | logback-demo 7 | 8 | 9 | mdc_filter 10 | 11 | ch.qos.logback.demo.UserServletFilter 12 | 13 | 14 | 15 | mdc_filter 16 | /* 17 | 18 | 19 | 20 | TeeFilter 21 | ch.qos.logback.access.servlet.TeeFilter 22 | 23 | 24 | 25 | TeeFilter 26 | /* 27 | 28 | 29 | 30 | 31 | 32 | JNDI logging context for this app 33 | logback/context-name 34 | java.lang.String 35 | DemoContext 36 | 37 | 38 | 39 | URL for configuring logback context 40 | logback/configuration-resource 41 | java.lang.String 42 | logback-demo.xml 43 | 44 | 45 | 46 | action 47 | 48 | org.apache.struts.action.ActionServlet 49 | 50 | 51 | config 52 | /WEB-INF/struts-config.xml 53 | 54 | 55 | debug 56 | 2 57 | 58 | 59 | detail 60 | 2 61 | 62 | 2 63 | 64 | 65 | 66 | 67 | 68 | action 69 | *.do 70 | 71 | 72 | 73 | 74 | 75 | index.jsp 76 | 77 | 78 | 79 | 80 | 81 | 82 | /tags/struts-bean 83 | /WEB-INF/struts-bean.tld 84 | 85 | 86 | 87 | /tags/struts-html 88 | /WEB-INF/struts-html.tld 89 | 90 | 91 | 92 | /tags/struts-logic 93 | /WEB-INF/struts-logic.tld 94 | 95 | 96 | 97 | /tags/struts-nested 98 | 99 | /WEB-INF/struts-nested.tld 100 | 101 | 102 | 103 | 104 | /tags/struts-tiles 105 | /WEB-INF/struts-tiles.tld 106 | 107 | 108 | 109 | 110 | 111 | ch.qos.logback.demo.ContextListener 112 | 113 | 114 | 115 | ViewLastLog 116 | ch.qos.logback.demo.ViewLastLog 117 | 118 | 119 | 120 | ViewStatusMessages 121 | ch.qos.logback.classic.ViewStatusMessagesServlet 122 | 123 | 124 | 125 | AccessViewStatusMessages 126 | ch.qos.logback.access.ViewStatusMessagesServlet 127 | 128 | 129 | 130 | ViewLastLog 131 | /lastLog/* 132 | 133 | 134 | 135 | ViewStatusMessages 136 | /lbClassicStatus 137 | 138 | 139 | 140 | AccessViewStatusMessages 141 | /lbAccessStatus 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/struts-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 17 | 18 | 20 | 21 | 23 | 24 | 26 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | 66 | 67 | 68 | 69 | 70 | 74 | 75 | 76 | 77 | 80 | 81 | 82 | 83 | 86 | 87 | 88 | 89 | 92 | 93 | 94 | 95 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 144 | 145 | 146 | 147 | 148 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 160 | 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/struts-tiles.tld: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1.2 12 | 1.1 13 | tiles 14 | http://struts.apache.org/tags-tiles 15 | 16 | insert 17 | org.apache.struts.taglib.tiles.InsertTag 18 | JSP 19 | 20 | template 21 | false 22 | true 23 | 24 | 25 | component 26 | false 27 | true 28 | 29 | 30 | page 31 | false 32 | true 33 | 34 | 35 | definition 36 | false 37 | true 38 | 39 | 40 | attribute 41 | false 42 | false 43 | 44 | 45 | name 46 | false 47 | true 48 | 49 | 50 | beanName 51 | false 52 | true 53 | 54 | 55 | beanProperty 56 | false 57 | true 58 | 59 | 60 | beanScope 61 | false 62 | false 63 | 64 | 65 | flush 66 | false 67 | false 68 | 69 | 70 | ignore 71 | false 72 | true 73 | 74 | 75 | role 76 | false 77 | true 78 | 79 | 80 | controllerUrl 81 | false 82 | true 83 | 84 | 85 | controllerClass 86 | false 87 | true 88 | 89 | 90 | 91 | definition 92 | org.apache.struts.taglib.tiles.DefinitionTag 93 | JSP 94 | 95 | id 96 | true 97 | false 98 | 99 | 100 | scope 101 | false 102 | false 103 | 104 | 105 | template 106 | false 107 | true 108 | 109 | 110 | page 111 | false 112 | true 113 | 114 | 115 | role 116 | false 117 | true 118 | 119 | 120 | extends 121 | false 122 | true 123 | 124 | 125 | 126 | put 127 | org.apache.struts.taglib.tiles.PutTag 128 | JSP 129 | 130 | name 131 | false 132 | false 133 | 134 | 135 | value 136 | false 137 | true 138 | 139 | 140 | content 141 | false 142 | true 143 | 144 | 145 | direct 146 | false 147 | false 148 | 149 | 150 | type 151 | false 152 | false 153 | 154 | 155 | beanName 156 | false 157 | true 158 | 159 | 160 | beanProperty 161 | false 162 | true 163 | 164 | 165 | beanScope 166 | false 167 | false 168 | 169 | 170 | role 171 | false 172 | true 173 | 174 | 175 | 176 | putList 177 | org.apache.struts.taglib.tiles.PutListTag 178 | JSP 179 | 180 | name 181 | true 182 | false 183 | 184 | 185 | 186 | add 187 | org.apache.struts.taglib.tiles.AddTag 188 | JSP 189 | 190 | value 191 | false 192 | false 193 | 194 | 195 | content 196 | false 197 | true 198 | 199 | 200 | direct 201 | false 202 | false 203 | 204 | 205 | type 206 | false 207 | false 208 | 209 | 210 | beanName 211 | false 212 | true 213 | 214 | 215 | beanProperty 216 | false 217 | true 218 | 219 | 220 | beanScope 221 | false 222 | false 223 | 224 | 225 | role 226 | false 227 | true 228 | 229 | 230 | 231 | get 232 | org.apache.struts.taglib.tiles.GetTag 233 | empty 234 | 235 | name 236 | true 237 | true 238 | 239 | 240 | ignore 241 | false 242 | true 243 | 244 | 245 | flush 246 | false 247 | false 248 | 249 | 250 | role 251 | false 252 | true 253 | 254 | 255 | 256 | getAsString 257 | org.apache.struts.taglib.tiles.GetAttributeTag 258 | empty 259 | 260 | name 261 | true 262 | true 263 | 264 | 265 | ignore 266 | false 267 | true 268 | 269 | 270 | role 271 | false 272 | true 273 | 274 | 275 | 276 | useAttribute 277 | org.apache.struts.taglib.tiles.UseAttributeTag 278 | org.apache.struts.taglib.tiles.UseAttributeTei 279 | empty 280 | 281 | id 282 | false 283 | false 284 | 285 | 286 | classname 287 | false 288 | false 289 | 290 | 291 | scope 292 | false 293 | false 294 | 295 | 296 | name 297 | true 298 | true 299 | 300 | 301 | ignore 302 | false 303 | true 304 | 305 | 306 | 307 | importAttribute 308 | org.apache.struts.taglib.tiles.ImportAttributeTag 309 | empty 310 | 311 | name 312 | false 313 | true 314 | 315 | 316 | scope 317 | false 318 | false 319 | 320 | 321 | ignore 322 | false 323 | true 324 | 325 | 326 | 327 | initComponentDefinitions 328 | org.apache.struts.taglib.tiles.InitDefinitionsTag 329 | empty 330 | 331 | file 332 | true 333 | false 334 | 335 | 336 | classname 337 | false 338 | false 339 | 340 | 341 | 342 | 343 | 344 | 345 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/struts-bean.tld: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1.2 12 | 1.1 13 | bean 14 | http://struts.apache.org/tags-bean 15 | 16 | cookie 17 | org.apache.struts.taglib.bean.CookieTag 18 | org.apache.struts.taglib.bean.CookieTei 19 | empty 20 | 21 | id 22 | true 23 | false 24 | 25 | 26 | multiple 27 | false 28 | true 29 | 30 | 31 | name 32 | true 33 | true 34 | 35 | 36 | value 37 | false 38 | true 39 | 40 | 41 | 42 | define 43 | org.apache.struts.taglib.bean.DefineTag 44 | org.apache.struts.taglib.bean.DefineTei 45 | JSP 46 | 47 | id 48 | true 49 | false 50 | 51 | 52 | name 53 | false 54 | true 55 | 56 | 57 | property 58 | false 59 | true 60 | 61 | 62 | scope 63 | false 64 | true 65 | 66 | 67 | toScope 68 | false 69 | true 70 | 71 | 72 | type 73 | false 74 | true 75 | 76 | 77 | value 78 | false 79 | true 80 | 81 | 82 | 83 | header 84 | org.apache.struts.taglib.bean.HeaderTag 85 | org.apache.struts.taglib.bean.HeaderTei 86 | empty 87 | 88 | id 89 | true 90 | false 91 | 92 | 93 | multiple 94 | false 95 | true 96 | 97 | 98 | name 99 | true 100 | true 101 | 102 | 103 | value 104 | false 105 | true 106 | 107 | 108 | 109 | include 110 | org.apache.struts.taglib.bean.IncludeTag 111 | org.apache.struts.taglib.bean.IncludeTei 112 | empty 113 | 114 | anchor 115 | false 116 | true 117 | 118 | 119 | forward 120 | false 121 | true 122 | 123 | 124 | href 125 | false 126 | true 127 | 128 | 129 | id 130 | true 131 | false 132 | 133 | 134 | name 135 | false 136 | true 137 | 138 | 139 | page 140 | false 141 | true 142 | 143 | 144 | transaction 145 | false 146 | true 147 | 148 | 149 | 150 | message 151 | org.apache.struts.taglib.bean.MessageTag 152 | empty 153 | 154 | arg0 155 | false 156 | true 157 | 158 | 159 | arg1 160 | false 161 | true 162 | 163 | 164 | arg2 165 | false 166 | true 167 | 168 | 169 | arg3 170 | false 171 | true 172 | 173 | 174 | arg4 175 | false 176 | true 177 | 178 | 179 | bundle 180 | false 181 | true 182 | 183 | 184 | key 185 | false 186 | true 187 | 188 | 189 | locale 190 | false 191 | true 192 | 193 | 194 | name 195 | false 196 | true 197 | 198 | 199 | property 200 | false 201 | true 202 | 203 | 204 | scope 205 | false 206 | true 207 | 208 | 209 | 210 | page 211 | org.apache.struts.taglib.bean.PageTag 212 | org.apache.struts.taglib.bean.PageTei 213 | empty 214 | 215 | id 216 | true 217 | false 218 | 219 | 220 | property 221 | true 222 | true 223 | 224 | 225 | 226 | parameter 227 | org.apache.struts.taglib.bean.ParameterTag 228 | org.apache.struts.taglib.bean.ParameterTei 229 | empty 230 | 231 | id 232 | true 233 | false 234 | 235 | 236 | multiple 237 | false 238 | true 239 | 240 | 241 | name 242 | true 243 | true 244 | 245 | 246 | value 247 | false 248 | true 249 | 250 | 251 | 252 | resource 253 | org.apache.struts.taglib.bean.ResourceTag 254 | org.apache.struts.taglib.bean.ResourceTei 255 | empty 256 | 257 | id 258 | true 259 | false 260 | 261 | 262 | input 263 | false 264 | true 265 | 266 | 267 | name 268 | true 269 | true 270 | 271 | 272 | 273 | size 274 | org.apache.struts.taglib.bean.SizeTag 275 | org.apache.struts.taglib.bean.SizeTei 276 | empty 277 | 278 | collection 279 | false 280 | true 281 | 282 | 283 | id 284 | true 285 | false 286 | 287 | 288 | name 289 | false 290 | true 291 | 292 | 293 | property 294 | false 295 | true 296 | 297 | 298 | scope 299 | false 300 | true 301 | 302 | 303 | 304 | struts 305 | org.apache.struts.taglib.bean.StrutsTag 306 | org.apache.struts.taglib.bean.StrutsTei 307 | empty 308 | 309 | id 310 | true 311 | false 312 | 313 | 314 | formBean 315 | false 316 | true 317 | 318 | 319 | forward 320 | false 321 | true 322 | 323 | 324 | mapping 325 | false 326 | true 327 | 328 | 329 | 330 | write 331 | org.apache.struts.taglib.bean.WriteTag 332 | empty 333 | 334 | bundle 335 | false 336 | true 337 | 338 | 339 | filter 340 | false 341 | true 342 | 343 | 344 | format 345 | false 346 | true 347 | 348 | 349 | formatKey 350 | false 351 | true 352 | 353 | 354 | ignore 355 | false 356 | true 357 | 358 | 359 | locale 360 | false 361 | true 362 | 363 | 364 | name 365 | true 366 | true 367 | 368 | 369 | property 370 | false 371 | true 372 | 373 | 374 | scope 375 | false 376 | true 377 | 378 | 379 | 380 | 381 | 382 | 383 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/validator-rules.xml: -------------------------------------------------------------------------------- 1 | 4 | 47 | 48 | 49 | 50 | 51 | 52 | 62 | 63 | 73 | 74 | 84 | 85 | 86 | 98 | 99 | 100 | 112 | 113 | 114 | 115 | 126 | 127 | 128 | 140 | 141 | 142 | 154 | 155 | 156 | 168 | 169 | 170 | 171 | 182 | 183 | 184 | 196 | 197 | 208 | 209 | 210 | 222 | 223 | 224 | 235 | 236 | 237 | 248 | 249 | 260 | 261 | 262 | 273 | 274 | 275 | 286 | 287 | 298 | 299 | 303 | 310 | 311 | 312 | 313 | 314 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/struts-logic.tld: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 1.2 11 | 1.1 12 | logic 13 | http://struts.apache.org/tags-logic 14 | 15 | empty 16 | org.apache.struts.taglib.logic.EmptyTag 17 | JSP 18 | 19 | name 20 | false 21 | true 22 | 23 | 24 | property 25 | false 26 | true 27 | 28 | 29 | scope 30 | false 31 | true 32 | 33 | 34 | 35 | equal 36 | org.apache.struts.taglib.logic.EqualTag 37 | JSP 38 | 39 | cookie 40 | false 41 | true 42 | 43 | 44 | header 45 | false 46 | true 47 | 48 | 49 | name 50 | false 51 | true 52 | 53 | 54 | parameter 55 | false 56 | true 57 | 58 | 59 | property 60 | false 61 | true 62 | 63 | 64 | scope 65 | false 66 | true 67 | 68 | 69 | value 70 | true 71 | true 72 | 73 | 74 | 75 | forward 76 | org.apache.struts.taglib.logic.ForwardTag 77 | empty 78 | 79 | name 80 | true 81 | true 82 | 83 | 84 | 85 | greaterEqual 86 | org.apache.struts.taglib.logic.GreaterEqualTag 87 | JSP 88 | 89 | cookie 90 | false 91 | true 92 | 93 | 94 | header 95 | false 96 | true 97 | 98 | 99 | name 100 | false 101 | true 102 | 103 | 104 | parameter 105 | false 106 | true 107 | 108 | 109 | property 110 | false 111 | true 112 | 113 | 114 | scope 115 | false 116 | true 117 | 118 | 119 | value 120 | true 121 | true 122 | 123 | 124 | 125 | greaterThan 126 | org.apache.struts.taglib.logic.GreaterThanTag 127 | JSP 128 | 129 | cookie 130 | false 131 | true 132 | 133 | 134 | header 135 | false 136 | true 137 | 138 | 139 | name 140 | false 141 | true 142 | 143 | 144 | parameter 145 | false 146 | true 147 | 148 | 149 | property 150 | false 151 | true 152 | 153 | 154 | scope 155 | false 156 | true 157 | 158 | 159 | value 160 | true 161 | true 162 | 163 | 164 | 165 | iterate 166 | org.apache.struts.taglib.logic.IterateTag 167 | org.apache.struts.taglib.logic.IterateTei 168 | JSP 169 | 170 | collection 171 | false 172 | true 173 | 174 | 175 | id 176 | true 177 | false 178 | 179 | 180 | indexId 181 | false 182 | false 183 | 184 | 185 | length 186 | false 187 | true 188 | 189 | 190 | name 191 | false 192 | true 193 | 194 | 195 | offset 196 | false 197 | true 198 | 199 | 200 | property 201 | false 202 | true 203 | 204 | 205 | scope 206 | false 207 | true 208 | 209 | 210 | type 211 | false 212 | true 213 | 214 | 215 | 216 | lessEqual 217 | org.apache.struts.taglib.logic.LessEqualTag 218 | JSP 219 | 220 | cookie 221 | false 222 | true 223 | 224 | 225 | header 226 | false 227 | true 228 | 229 | 230 | name 231 | false 232 | true 233 | 234 | 235 | parameter 236 | false 237 | true 238 | 239 | 240 | property 241 | false 242 | true 243 | 244 | 245 | scope 246 | false 247 | true 248 | 249 | 250 | value 251 | true 252 | true 253 | 254 | 255 | 256 | lessThan 257 | org.apache.struts.taglib.logic.LessThanTag 258 | JSP 259 | 260 | cookie 261 | false 262 | true 263 | 264 | 265 | header 266 | false 267 | true 268 | 269 | 270 | name 271 | false 272 | true 273 | 274 | 275 | parameter 276 | false 277 | true 278 | 279 | 280 | property 281 | false 282 | true 283 | 284 | 285 | scope 286 | false 287 | true 288 | 289 | 290 | value 291 | true 292 | true 293 | 294 | 295 | 296 | match 297 | org.apache.struts.taglib.logic.MatchTag 298 | JSP 299 | 300 | cookie 301 | false 302 | true 303 | 304 | 305 | header 306 | false 307 | true 308 | 309 | 310 | location 311 | false 312 | true 313 | 314 | 315 | name 316 | false 317 | true 318 | 319 | 320 | parameter 321 | false 322 | true 323 | 324 | 325 | property 326 | false 327 | true 328 | 329 | 330 | scope 331 | false 332 | true 333 | 334 | 335 | value 336 | true 337 | true 338 | 339 | 340 | 341 | messagesNotPresent 342 | org.apache.struts.taglib.logic.MessagesNotPresentTag 343 | JSP 344 | 345 | name 346 | false 347 | true 348 | 349 | 350 | property 351 | false 352 | true 353 | 354 | 355 | message 356 | false 357 | true 358 | 359 | 360 | 361 | messagesPresent 362 | org.apache.struts.taglib.logic.MessagesPresentTag 363 | JSP 364 | 365 | name 366 | false 367 | true 368 | 369 | 370 | property 371 | false 372 | true 373 | 374 | 375 | message 376 | false 377 | true 378 | 379 | 380 | 381 | notEmpty 382 | org.apache.struts.taglib.logic.NotEmptyTag 383 | JSP 384 | 385 | name 386 | false 387 | true 388 | 389 | 390 | property 391 | false 392 | true 393 | 394 | 395 | scope 396 | false 397 | true 398 | 399 | 400 | 401 | notEqual 402 | org.apache.struts.taglib.logic.NotEqualTag 403 | JSP 404 | 405 | cookie 406 | false 407 | true 408 | 409 | 410 | header 411 | false 412 | true 413 | 414 | 415 | name 416 | false 417 | true 418 | 419 | 420 | parameter 421 | false 422 | true 423 | 424 | 425 | property 426 | false 427 | true 428 | 429 | 430 | scope 431 | false 432 | true 433 | 434 | 435 | value 436 | true 437 | true 438 | 439 | 440 | 441 | notMatch 442 | org.apache.struts.taglib.logic.NotMatchTag 443 | JSP 444 | 445 | cookie 446 | false 447 | true 448 | 449 | 450 | header 451 | false 452 | true 453 | 454 | 455 | location 456 | false 457 | true 458 | 459 | 460 | name 461 | false 462 | true 463 | 464 | 465 | parameter 466 | false 467 | true 468 | 469 | 470 | property 471 | false 472 | true 473 | 474 | 475 | scope 476 | false 477 | true 478 | 479 | 480 | value 481 | true 482 | true 483 | 484 | 485 | 486 | notPresent 487 | org.apache.struts.taglib.logic.NotPresentTag 488 | JSP 489 | 490 | cookie 491 | false 492 | true 493 | 494 | 495 | header 496 | false 497 | true 498 | 499 | 500 | name 501 | false 502 | true 503 | 504 | 505 | parameter 506 | false 507 | true 508 | 509 | 510 | property 511 | false 512 | true 513 | 514 | 515 | role 516 | false 517 | true 518 | 519 | 520 | scope 521 | false 522 | true 523 | 524 | 525 | user 526 | false 527 | true 528 | 529 | 530 | 531 | present 532 | org.apache.struts.taglib.logic.PresentTag 533 | JSP 534 | 535 | cookie 536 | false 537 | true 538 | 539 | 540 | header 541 | false 542 | true 543 | 544 | 545 | name 546 | false 547 | true 548 | 549 | 550 | parameter 551 | false 552 | true 553 | 554 | 555 | property 556 | false 557 | true 558 | 559 | 560 | role 561 | false 562 | true 563 | 564 | 565 | scope 566 | false 567 | true 568 | 569 | 570 | user 571 | false 572 | true 573 | 574 | 575 | 576 | redirect 577 | org.apache.struts.taglib.logic.RedirectTag 578 | 579 | action 580 | false 581 | true 582 | 583 | 584 | anchor 585 | false 586 | true 587 | 588 | 589 | forward 590 | false 591 | true 592 | 593 | 594 | href 595 | false 596 | true 597 | 598 | 599 | name 600 | false 601 | true 602 | 603 | 604 | page 605 | false 606 | true 607 | 608 | 609 | paramId 610 | false 611 | true 612 | 613 | 614 | paramName 615 | false 616 | true 617 | 618 | 619 | paramProperty 620 | false 621 | true 622 | 623 | 624 | paramScope 625 | false 626 | true 627 | 628 | 629 | property 630 | false 631 | true 632 | 633 | 634 | scope 635 | false 636 | true 637 | 638 | 639 | transaction 640 | false 641 | true 642 | 643 | 644 | useLocalEncoding 645 | false 646 | true 647 | 648 | 649 | 650 | 651 | 652 | 653 | --------------------------------------------------------------------------------