diff --git a/logback-access/LICENSE.txt b/logback-access/LICENSE.txt deleted file mode 100644 index af39fcb95d..0000000000 --- a/logback-access/LICENSE.txt +++ /dev/null @@ -1,15 +0,0 @@ -Logback LICENSE ---------------- - -Logback: the reliable, generic, fast and flexible logging framework. -Copyright (C) 1999-2015, QOS.ch. All rights reserved. - -This program and the accompanying materials are dual-licensed under -either the terms of the Eclipse Public License v1.0 as published by -the Eclipse Foundation - - or (per the licensee's choosing) - -under the terms of the GNU Lesser General Public License version 2.1 -as published by the Free Software Foundation. - diff --git a/logback-access/build.xml b/logback-access/build.xml deleted file mode 100644 index e7728ead92..0000000000 --- a/logback-access/build.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - These are the targets supported by this ANT build scpript: - - build - compile all project files, if a certain library is missing, - then the compilation of its dependents are skipped. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
-
- - -
diff --git a/logback-access/keywords.html b/logback-access/keywords.html deleted file mode 100644 index 366044dba3..0000000000 --- a/logback-access/keywords.html +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
keyword LabelJettyResinTomcatObservations
aremote IP addressNANArequest.getRemoteAddr() [S] RemoteIPAddressConverter
Alocal IP address InetAddress.getLocalHost().getHostAddress() [S] LocalIPAddressConverter
bContent lengthrequest.getConnection().getGenerator().getContentWritten();Unless statusCode==304, response.getContentLength()response.getContentCount();JettyContentLengthConverter, ResinContentLengthConverter
cCookierequest cookies (dumps all of them}dumps cookies by name, request cookie first, if - unavailable then response cookierequest cookies, by nameRequestCookieConverter
hremote IP addrrequest.getRemoteAddr() [S]request.printRemoteAddr, IP address string in textual presentationrequest.getRemoteHost() [S]RemoteHostConverter
Hrequest protocolrequest.getProtocol()RequestProtocolConverter
iIncoming headerNArequest.getHeader(name) [S]request.getHeader(header) [S]RequestHeaderConverter
lRemote logical username from identdalways '-'always '-'always '-'NAConverter
nattribute in the ServletRequestNArequest.getAttribute(name) [S] NARequestAttributeConverter, in tomcat %r is used
oresponse headerresponse.getHeader(name) [NS]not implemented although response.setHeader() method is available
rFirst line of the request (method and request URI)request.getMethod()+ request.getUri() [NS] +request.getProtocol()request.getMethod() + request.getUriBuffer() [NS] + request.getProtocol()request.getMethod() + request.getRequestURI() + request.getQueryString() + '?' + request.getProtocol();RequestURLConverter
{}rattribute in the ServletRequestNANArequest.getAttribute(name) [S]RequestAttributeConverter, in resin %n is used
sstatus coderesponse.getStatus() [NS] response.getStatusCode() [NS]response.getStatus() [NS]surprisingly, not in the Servlet API
{}trequest time stampgetTimeStamp() [NS]based on current timebased on current timeDateConverter
Trequest processing duration in secondsNArequest.getStartTime() - Alarm.getExactTime()Valve measures invocation time
Drequest processing duration in millisrequest.getStartTime() - Alarm.getExactTime()Valve measures invocation time
uremote userrequest.getRemoteUser() [S]request.getRemoteUser() [S]request.getRemoteUser() [S]RemoteUserConverter
URequested URI pathNA request.getRequestURI() [S} request.getRequestURI() [S}RequestURIConverter
- - -Tomcat -====== -%a - Remote IP address -%A - Local IP address -%b - Bytes sent, excluding HTTP headers, or '-' if zero -%B - Bytes sent, excluding HTTP headers -%h - Remote host name (or IP address if resolveHosts is false) -%H - Request protocol -%l - Remote logical username from identd (always returns '-') -%m - Request method (GET, POST, etc.) -%p - Local port on which this request was received -%q - Query string (prepended with a '?' if it exists) -%r - First line of the request (method and request URI) -%s - HTTP status code of the response -%S - User session ID -%t - Date and time, in Common Log Format -%u - Remote user that was authenticated (if any), else '-' -%U - Requested URL path -%v - Local server name -%D - Time taken to process the request, in millis -%T - Time taken to process the request, in seconds - -Resin -===== - - - - diff --git a/logback-access/pom.xml b/logback-access/pom.xml deleted file mode 100755 index 5bce931ebf..0000000000 --- a/logback-access/pom.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - - 4.0.0 - - - ch.qos.logback - logback-parent - 1.5.0-SNAPSHOT - - - logback-access - jar - Logback Access Module - logback-access module - - - ch.qos.logback.access - - - - - org.junit.jupiter - junit-jupiter-params - ${junit-jupiter-params.version} - test - - - - ch.qos.logback - logback-core - compile - - - ch.qos.logback - logback-core - test-jar - test - - - - jakarta.servlet - jakarta.servlet-api - provided - - - - org.apache.tomcat - tomcat-catalina - compile - true - - - org.apache.tomcat - tomcat-coyote - compile - true - - - org.eclipse.jetty - jetty-server - compile - true - - - org.codehaus.janino - janino - compile - true - - - - jakarta.mail - jakarta.mail-api - compile - true - - - - jakarta.activation - jakarta.activation-api - compile - true - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - once - - plain - true - - **/AllAccessTest.java - **/PackageTest.java - **/SerializationPerfTest.java - - - - - org.apache.maven.plugins - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - - - bundle-test-jar - package - - test-jar - - - - - - org.apache.felix - maven-bundle-plugin - - - bundle-manifest - process-classes - - manifest - - - - - - ch.qos.logback.access.* - - - ch.qos.logback.access*;version="${range;[==,+);${version_cleanup;${project.version}}}", - ch.qos.logback.core.rolling, - ch.qos.logback.core.rolling.helper, - org.apache.catalina.*;version="${tomcat.version}";resolution:=optional, - org.eclipse.jetty.*;version="${jetty.version}";resolution:=optional, - * - - - - - - - - - - - diff --git a/logback-access/src/main/java/ch/qos/logback/access/AccessConstants.java b/logback-access/src/main/java/ch/qos/logback/access/AccessConstants.java deleted file mode 100644 index 722744af7e..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/AccessConstants.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access; - -public class AccessConstants { - - public static final String LOGBACK_STATUS_MANAGER_KEY = "LOGBACK_STATUS_MANAGER"; - public static final String LB_INPUT_BUFFER = "LB_INPUT_BUFFER"; - public static final String LB_OUTPUT_BUFFER = "LB_OUTPUT_BUFFER"; - - public static final String X_WWW_FORM_URLECODED = "application/x-www-form-urlencoded"; - - public static final String IMAGE_CONTENT_TYPE = "image/"; - public static final String IMAGE_JPEG = "image/jpeg"; - public static final String IMAGE_GIF = "image/gif"; - public static final String IMAGE_PNG = "image/png"; - - public static final String TEE_FILTER_INCLUDES_PARAM = "includes"; - public static final String TEE_FILTER_EXCLUDES_PARAM = "excludes"; - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/PatternLayout.java b/logback-access/src/main/java/ch/qos/logback/access/PatternLayout.java deleted file mode 100644 index f2724042a1..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/PatternLayout.java +++ /dev/null @@ -1,217 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access; - -import ch.qos.logback.access.pattern.ContentLengthConverter; -import ch.qos.logback.access.pattern.DateConverter; -import ch.qos.logback.access.pattern.ElapsedSecondsConverter; -import ch.qos.logback.access.pattern.ElapsedTimeConverter; -import ch.qos.logback.access.pattern.EnsureLineSeparation; -import ch.qos.logback.access.pattern.FullRequestConverter; -import ch.qos.logback.access.pattern.FullResponseConverter; -import ch.qos.logback.access.pattern.LineSeparatorConverter; -import ch.qos.logback.access.pattern.LocalIPAddressConverter; -import ch.qos.logback.access.pattern.LocalPortConverter; -import ch.qos.logback.access.pattern.NAConverter; -import ch.qos.logback.access.pattern.QueryStringConverter; -import ch.qos.logback.access.pattern.RemoteHostConverter; -import ch.qos.logback.access.pattern.RemoteIPAddressConverter; -import ch.qos.logback.access.pattern.RemoteUserConverter; -import ch.qos.logback.access.pattern.RequestAttributeConverter; -import ch.qos.logback.access.pattern.RequestContentConverter; -import ch.qos.logback.access.pattern.RequestCookieConverter; -import ch.qos.logback.access.pattern.RequestHeaderConverter; -import ch.qos.logback.access.pattern.RequestMethodConverter; -import ch.qos.logback.access.pattern.RequestParameterConverter; -import ch.qos.logback.access.pattern.RequestProtocolConverter; -import ch.qos.logback.access.pattern.RequestURIConverter; -import ch.qos.logback.access.pattern.RequestURLConverter; -import ch.qos.logback.access.pattern.ResponseContentConverter; -import ch.qos.logback.access.pattern.ResponseHeaderConverter; -import ch.qos.logback.access.pattern.ServerNameConverter; -import ch.qos.logback.access.pattern.SessionIDConverter; -import ch.qos.logback.access.pattern.StatusCodeConverter; -import ch.qos.logback.access.pattern.ThreadNameConverter; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.pattern.PatternLayoutBase; -import ch.qos.logback.core.pattern.color.*; -import ch.qos.logback.core.pattern.parser.Parser; - -import java.util.HashMap; -import java.util.Map; - -/** - *

- * This class is a module-specific implementation of - * {@link ch.qos.logback.access.PatternLayout} to allow http-specific patterns - * to be used. The ch.qos.logback.access.PatternLayout provides a - * way to format the logging output that is just as easy and flexible as the - * usual PatternLayout. - *

- *

- * For more information about this layout, please refer to the online manual at - * http://logback.qos.ch/manual/layouts.html#AccessPatternLayout - * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ -public class PatternLayout extends PatternLayoutBase { - - public static final Map defaultConverterMap = new HashMap(); - public static final String HEADER_PREFIX = "#logback.access pattern: "; - - public static final String CLF_PATTERN = "%h %l %u [%t] \"%r\" %s %b"; - public static final String CLF_PATTERN_NAME = "common"; - public static final String CLF_PATTERN_NAME_2 = "clf"; - public static final String COMBINED_PATTERN = "%h %l %u [%t] \"%r\" %s %b \"%i{Referer}\" \"%i{User-Agent}\""; - public static final String COMBINED_PATTERN_NAME = "combined"; - - static { - defaultConverterMap.putAll(Parser.DEFAULT_COMPOSITE_CONVERTER_MAP); - - defaultConverterMap.put("a", RemoteIPAddressConverter.class.getName()); - defaultConverterMap.put("remoteIP", RemoteIPAddressConverter.class.getName()); - - defaultConverterMap.put("A", LocalIPAddressConverter.class.getName()); - defaultConverterMap.put("localIP", LocalIPAddressConverter.class.getName()); - - defaultConverterMap.put("b", ContentLengthConverter.class.getName()); - defaultConverterMap.put("B", ContentLengthConverter.class.getName()); - defaultConverterMap.put("bytesSent", ContentLengthConverter.class.getName()); - - defaultConverterMap.put("h", RemoteHostConverter.class.getName()); - defaultConverterMap.put("clientHost", RemoteHostConverter.class.getName()); - - defaultConverterMap.put("H", RequestProtocolConverter.class.getName()); - defaultConverterMap.put("protocol", RequestProtocolConverter.class.getName()); - - defaultConverterMap.put("i", RequestHeaderConverter.class.getName()); - defaultConverterMap.put("header", RequestHeaderConverter.class.getName()); - - defaultConverterMap.put("I", ThreadNameConverter.class.getName()); - defaultConverterMap.put("threadName", ThreadNameConverter.class.getName()); - - defaultConverterMap.put("l", NAConverter.class.getName()); - - defaultConverterMap.put("m", RequestMethodConverter.class.getName()); - defaultConverterMap.put("requestMethod", RequestMethodConverter.class.getName()); - - defaultConverterMap.put("q", QueryStringConverter.class.getName()); - defaultConverterMap.put("queryString", QueryStringConverter.class.getName()); - - defaultConverterMap.put("r", RequestURLConverter.class.getName()); - defaultConverterMap.put("requestURL", RequestURLConverter.class.getName()); - - defaultConverterMap.put("s", StatusCodeConverter.class.getName()); - defaultConverterMap.put("statusCode", StatusCodeConverter.class.getName()); - - defaultConverterMap.put("S", SessionIDConverter.class.getName()); - defaultConverterMap.put("sessionID", SessionIDConverter.class.getName()); - - defaultConverterMap.put("t", DateConverter.class.getName()); - defaultConverterMap.put("date", DateConverter.class.getName()); - - defaultConverterMap.put("u", RemoteUserConverter.class.getName()); - defaultConverterMap.put("user", RemoteUserConverter.class.getName()); - - defaultConverterMap.put("U", RequestURIConverter.class.getName()); - defaultConverterMap.put("requestURI", RequestURIConverter.class.getName()); - - defaultConverterMap.put("v", ServerNameConverter.class.getName()); - defaultConverterMap.put("server", ServerNameConverter.class.getName()); - - defaultConverterMap.put("localPort", LocalPortConverter.class.getName()); - - defaultConverterMap.put("requestAttribute", RequestAttributeConverter.class.getName()); - defaultConverterMap.put("reqAttribute", RequestAttributeConverter.class.getName()); - - defaultConverterMap.put("reqCookie", RequestCookieConverter.class.getName()); - defaultConverterMap.put("requestCookie", RequestCookieConverter.class.getName()); - - defaultConverterMap.put("responseHeader", ResponseHeaderConverter.class.getName()); - - defaultConverterMap.put("requestParameter", RequestParameterConverter.class.getName()); - defaultConverterMap.put("reqParameter", RequestParameterConverter.class.getName()); - - defaultConverterMap.put("requestContent", RequestContentConverter.class.getName()); - - defaultConverterMap.put("responseContent", ResponseContentConverter.class.getName()); - - defaultConverterMap.put("fullRequest", FullRequestConverter.class.getName()); - defaultConverterMap.put("fullResponse", FullResponseConverter.class.getName()); - - defaultConverterMap.put("elapsedTime", ElapsedTimeConverter.class.getName()); - defaultConverterMap.put("D", ElapsedTimeConverter.class.getName()); - - defaultConverterMap.put("elapsedSeconds", ElapsedSecondsConverter.class.getName()); - defaultConverterMap.put("T", ElapsedSecondsConverter.class.getName()); - - defaultConverterMap.put("n", LineSeparatorConverter.class.getName()); - - defaultConverterMap.put("black", BlackCompositeConverter.class.getName()); - defaultConverterMap.put("red", RedCompositeConverter.class.getName()); - defaultConverterMap.put("green", GreenCompositeConverter.class.getName()); - defaultConverterMap.put("yellow", YellowCompositeConverter.class.getName()); - defaultConverterMap.put("blue", BlueCompositeConverter.class.getName()); - defaultConverterMap.put("magenta", MagentaCompositeConverter.class.getName()); - defaultConverterMap.put("cyan", CyanCompositeConverter.class.getName()); - defaultConverterMap.put("white", WhiteCompositeConverter.class.getName()); - defaultConverterMap.put("gray", GrayCompositeConverter.class.getName()); - defaultConverterMap.put("boldRed", BoldRedCompositeConverter.class.getName()); - defaultConverterMap.put("boldGreen", BoldGreenCompositeConverter.class.getName()); - defaultConverterMap.put("boldYellow", BoldYellowCompositeConverter.class.getName()); - defaultConverterMap.put("boldBlue", BoldBlueCompositeConverter.class.getName()); - defaultConverterMap.put("boldMagenta", BoldMagentaCompositeConverter.class.getName()); - defaultConverterMap.put("boldCyan", BoldCyanCompositeConverter.class.getName()); - defaultConverterMap.put("boldWhite", BoldWhiteCompositeConverter.class.getName()); - } - - public PatternLayout() { - // set a default value for pattern - setPattern(CLF_PATTERN); - // by default postCompileProcessor is an EnsureLineSeparation instance - this.postCompileProcessor = new EnsureLineSeparation(); - } - - /** - * Returns the default converter map for this instance. - */ - @Override - public Map getDefaultConverterMap() { - return defaultConverterMap; - } - - @Override - public String doLayout(IAccessEvent event) { - if (!isStarted()) { - return null; - } - return writeLoopOnConverters(event); - } - - @Override - public void start() { - if (getPattern().equalsIgnoreCase(CLF_PATTERN_NAME) || getPattern().equalsIgnoreCase(CLF_PATTERN_NAME_2)) { - setPattern(CLF_PATTERN); - } else if (getPattern().equalsIgnoreCase(COMBINED_PATTERN_NAME)) { - setPattern(COMBINED_PATTERN); - } - super.start(); - } - - @Override - protected String getPresentationHeaderPrefix() { - return HEADER_PREFIX; - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/PatternLayoutEncoder.java b/logback-access/src/main/java/ch/qos/logback/access/PatternLayoutEncoder.java deleted file mode 100644 index 92c4a019fc..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/PatternLayoutEncoder.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.pattern.PatternLayoutEncoderBase; - -public class PatternLayoutEncoder extends PatternLayoutEncoderBase { - - @Override - public void start() { - PatternLayout patternLayout = new PatternLayout(); - patternLayout.setContext(context); - patternLayout.setPattern(getPattern()); - patternLayout.start(); - this.layout = patternLayout; - super.start(); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/ViewStatusMessagesServlet.java b/logback-access/src/main/java/ch/qos/logback/access/ViewStatusMessagesServlet.java deleted file mode 100644 index 1658380874..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/ViewStatusMessagesServlet.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access; - -import jakarta.servlet.ServletContext; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -import ch.qos.logback.core.status.StatusManager; -import ch.qos.logback.core.status.ViewStatusMessagesServletBase; - -public class ViewStatusMessagesServlet extends ViewStatusMessagesServletBase { - - private static final long serialVersionUID = 443878494348593337L; - - @Override - protected StatusManager getStatusManager(HttpServletRequest req, HttpServletResponse resp) { - - ServletContext sc = getServletContext(); - return (StatusManager) sc.getAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY); - - // if (result != null) { - // System.out.println("from ServletContext"); - // return result; - // } else { - // HttpSession httpSession = req.getSession(true); - // - // System.out.println("from httpSession"); - // return (StatusManager) httpSession - // .getAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY); - // } - } - - @Override - protected String getPageTitle(HttpServletRequest req, HttpServletResponse resp) { - return "

Status messages for logback-access

\r\n"; - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/boolex/JaninoEventEvaluator.java b/logback-access/src/main/java/ch/qos/logback/access/boolex/JaninoEventEvaluator.java deleted file mode 100644 index 7ba5a4bbff..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/boolex/JaninoEventEvaluator.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.boolex; - -import java.util.ArrayList; -import java.util.List; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.boolex.JaninoEventEvaluatorBase; -import ch.qos.logback.core.boolex.Matcher; - -public class JaninoEventEvaluator extends JaninoEventEvaluatorBase { - - public final static List DEFAULT_PARAM_NAME_LIST = new ArrayList<>(); - public final static List> DEFAULT_PARAM_TYPE_LIST = new ArrayList<>(); - - static { - DEFAULT_PARAM_NAME_LIST.add("event"); - DEFAULT_PARAM_TYPE_LIST.add(IAccessEvent.class); - } - - @Override - protected String getDecoratedExpression() { - String expression = getExpression(); - if (!expression.contains("return")) { - expression = "return " + expression + ";"; - addInfo("Adding [return] prefix and a semicolon suffix. Expression becomes [" + expression + "]"); - addInfo("See also " + CoreConstants.CODES_URL + "#block"); - } - return expression; - } - - @Override - protected String[] getParameterNames() { - List fullNameList = new ArrayList(); - fullNameList.addAll(DEFAULT_PARAM_NAME_LIST); - - for (int i = 0; i < matcherList.size(); i++) { - Matcher m = (Matcher) matcherList.get(i); - fullNameList.add(m.getName()); - } - - return (String[]) fullNameList.toArray(CoreConstants.EMPTY_STRING_ARRAY); - } - - @Override - protected Class[] getParameterTypes() { - List> fullTypeList = new ArrayList<>(); - fullTypeList.addAll(DEFAULT_PARAM_TYPE_LIST); - for (int i = 0; i < matcherList.size(); i++) { - fullTypeList.add(Matcher.class); - } - return (Class[]) fullTypeList.toArray(CoreConstants.EMPTY_CLASS_ARRAY); - } - - @Override - protected Object[] getParameterValues(IAccessEvent accessEvent) { - final int matcherListSize = matcherList.size(); - - int i = 0; - Object[] values = new Object[DEFAULT_PARAM_NAME_LIST.size() + matcherListSize]; - - values[i++] = accessEvent; - - for (int j = 0; j < matcherListSize; j++) { - values[i++] = matcherList.get(j); - } - - return values; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java b/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java deleted file mode 100644 index 21932ca120..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.filter; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.filter.Filter; -import ch.qos.logback.core.spi.FilterReply; - -import javax.management.MBeanServer; -import javax.management.ObjectName; -import javax.management.StandardMBean; -import java.lang.management.ManagementFactory; - -public class CountingFilter extends Filter { - - long total = 0; - final StatisticalViewImpl accessStatsImpl; - - String domain = "ch.qos.logback.access"; - - public CountingFilter() { - accessStatsImpl = new StatisticalViewImpl(this); - } - - @Override - public FilterReply decide(IAccessEvent event) { - total++; - accessStatsImpl.update(); - return FilterReply.NEUTRAL; - } - - public long getTotal() { - return total; - } - - @Override - public void start() { - MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); - try { - ObjectName on = new ObjectName(domain + ":Name=" + getName()); - StandardMBean mbean = new StandardMBean(accessStatsImpl, StatisticalView.class); - if (mbs.isRegistered(on)) { - mbs.unregisterMBean(on); - } - mbs.registerMBean(mbean, on); - super.start(); - } catch (Exception e) { - addError("Failed to create mbean", e); - } - } - - @Override - public void stop() { - super.stop(); - try { - MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); - ObjectName on = new ObjectName("totp:Filter=1"); - mbs.unregisterMBean(on); - } catch (Exception e) { - addError("Failed to unregister mbean", e); - } - } - - public String getDomain() { - return domain; - } - - public void setDomain(String domain) { - this.domain = domain; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/PeriodicStats.java b/logback-access/src/main/java/ch/qos/logback/access/filter/PeriodicStats.java deleted file mode 100644 index f1019564b1..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/PeriodicStats.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.filter; - -abstract public class PeriodicStats { - - private long nextPeriodBegins = 0; - private long lastTotal = 0; - private long lastCount = 0; - - private double average; - private int n; - - PeriodicStats() { - this(System.currentTimeMillis()); - } - - PeriodicStats(long now) { - nextPeriodBegins = computeStartOfNextPeriod(now); - } - - void update(long now, long total) { - if (now > nextPeriodBegins) { - lastCount = total - lastTotal; - lastTotal = total; - average = (average * n + lastCount) / (++n); - nextPeriodBegins = computeStartOfNextPeriod(now); - } - } - - public double getAverage() { - return average; - } - - public long getLastCount() { - return lastCount; - } - - void reset(long now) { - nextPeriodBegins = computeStartOfNextPeriod(now); - lastTotal = 0; - lastCount = 0; - average = 0.0; - n = 0; - } - - void reset() { - reset(System.currentTimeMillis()); - } - - abstract long computeStartOfNextPeriod(long now); - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalView.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalView.java deleted file mode 100644 index 9df3028cc8..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalView.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.filter; - -public interface StatisticalView { - - long getTotal(); - - long getLastMinuteCount(); - - double getMinuteAverage(); - - long getLastHoursCount(); - - double getHourlyAverage(); - - long getLastDaysCount(); - - double getDailyAverage(); - - long getLastWeeksCount(); - - double getWeeklyAverage(); - - long getLastMonthsCount(); - - double getMonthlyAverage(); - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalViewImpl.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalViewImpl.java deleted file mode 100644 index 0b1fb25fae..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalViewImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.filter; - -import ch.qos.logback.core.spi.LifeCycle; - -public class StatisticalViewImpl implements StatisticalView, LifeCycle { - - final CountingFilter countingFilter; - boolean started; - - StatsByMinute statsByMinute = new StatsByMinute(); - StatsByHour statsByHour = new StatsByHour(); - StatsByDay statsByDay = new StatsByDay(); - StatsByWeek statsByWeek = new StatsByWeek(); - StatsByMonth statsByMonth = new StatsByMonth(); - - StatisticalViewImpl(CountingFilter countingFilter) { - this.countingFilter = countingFilter; - } - - @Override - public double getDailyAverage() { - return statsByDay.getAverage(); - } - - @Override - public long getLastDaysCount() { - return statsByDay.getLastCount(); - } - - @Override - public double getMonthlyAverage() { - return statsByMonth.getAverage(); - } - - @Override - public long getLastMonthsCount() { - return statsByMonth.getLastCount(); - } - - @Override - public long getTotal() { - return countingFilter.getTotal(); - } - - @Override - public double getWeeklyAverage() { - return statsByWeek.getAverage(); - } - - @Override - public long getLastWeeksCount() { - return statsByWeek.getLastCount(); - } - - void update(long now) { - long total = getTotal(); - statsByMinute.update(now, total); - statsByHour.update(now, total); - statsByDay.update(now, total); - statsByWeek.update(now, total); - statsByMonth.update(now, total); - - } - - void update() { - long now = System.currentTimeMillis(); - update(now); - } - - @Override - public void start() { - System.out.println("StatisticalViewImpl start called"); - started = true; - long now = System.currentTimeMillis(); - statsByMinute = new StatsByMinute(now); - statsByHour = new StatsByHour(now); - statsByDay = new StatsByDay(now); - statsByWeek = new StatsByWeek(now); - statsByMonth = new StatsByMonth(now); - } - - @Override - public boolean isStarted() { - return started; - } - - @Override - public void stop() { - started = false; - statsByMinute.reset(); - statsByHour.reset(); - statsByDay.reset(); - statsByWeek.reset(); - statsByMonth.reset(); - } - - @Override - public long getLastMinuteCount() { - return statsByMinute.getLastCount(); - } - - @Override - public double getMinuteAverage() { - return statsByMinute.getAverage(); - } - - @Override - public double getHourlyAverage() { - return statsByHour.getAverage(); - } - - @Override - public long getLastHoursCount() { - return statsByHour.getLastCount(); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByDay.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByDay.java deleted file mode 100644 index d03f4a7989..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByDay.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.filter; - -import ch.qos.logback.core.util.TimeUtil; - -public class StatsByDay extends PeriodicStats { - - StatsByDay() { - super(); - } - - StatsByDay(long now) { - super(now); - } - - @Override - long computeStartOfNextPeriod(long now) { - return TimeUtil.computeStartOfNextDay(now); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByHour.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByHour.java deleted file mode 100644 index 26d82507ad..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByHour.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.filter; - -import ch.qos.logback.core.util.TimeUtil; - -public class StatsByHour extends PeriodicStats { - - StatsByHour() { - super(); - } - - StatsByHour(long now) { - super(now); - } - - @Override - long computeStartOfNextPeriod(long now) { - return TimeUtil.computeStartOfNextHour(now); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMinute.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMinute.java deleted file mode 100644 index c29e45c7af..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMinute.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.filter; - -import ch.qos.logback.core.util.TimeUtil; - -public class StatsByMinute extends PeriodicStats { - - StatsByMinute() { - super(); - } - - StatsByMinute(long now) { - super(now); - } - - @Override - long computeStartOfNextPeriod(long now) { - return TimeUtil.computeStartOfNextMinute(now); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMonth.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMonth.java deleted file mode 100644 index 74e630e9ef..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMonth.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.filter; - -import ch.qos.logback.core.util.TimeUtil; - -public class StatsByMonth extends PeriodicStats { - - StatsByMonth() { - super(); - } - - StatsByMonth(long now) { - super(now); - } - - @Override - long computeStartOfNextPeriod(long now) { - return TimeUtil.computeStartOfNextMonth(now); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByWeek.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByWeek.java deleted file mode 100644 index 177ba6bbb7..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByWeek.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.filter; - -import ch.qos.logback.core.util.TimeUtil; - -public class StatsByWeek extends PeriodicStats { - - StatsByWeek() { - super(); - } - - StatsByWeek(long now) { - super(now); - } - - @Override - long computeStartOfNextPeriod(long now) { - return TimeUtil.computeStartOfNextWeek(now); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/html/DefaultCssBuilder.java b/logback-access/src/main/java/ch/qos/logback/access/html/DefaultCssBuilder.java deleted file mode 100644 index 1a42c441c5..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/html/DefaultCssBuilder.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.html; - -import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR; -import ch.qos.logback.core.html.CssBuilder; - -/** - * This class helps the HTMLLayout build the CSS link. It either provides the - * HTMLLayout with a default css file, or builds the link to an external, - * user-specified, file. - * - * @author Sébastien Pennec - */ -public class DefaultCssBuilder implements CssBuilder { - - @Override - public void addCss(StringBuilder sbuf) { - sbuf.append(""); - } -} \ No newline at end of file diff --git a/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java b/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java deleted file mode 100644 index 952672daaa..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.html; - -import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR; - -import java.util.Map; - -import ch.qos.logback.access.PatternLayout; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.html.HTMLLayoutBase; -import ch.qos.logback.core.pattern.Converter; - -/** - * - * HTMLLayout outputs events in an HTML table. - *

- * The content of the table columns are specified using a conversion pattern. - * See {@link ch.qos.logback.access.PatternLayout} for documentation on the - * available patterns. - *

- * For more information about this layout, please refer to the online manual at - * http://logback.qos.ch/manual/layouts.html#AccessHTMLLayout - * - * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ -public class HTMLLayout extends HTMLLayoutBase { - - /** - * Default pattern string for log output. - */ - static final String DEFAULT_CONVERSION_PATTERN = "%h%l%u%t%r%s%b"; - - /** - * Constructs a PatternLayout using the DEFAULT_LAYOUT_PATTERN. - * - */ - public HTMLLayout() { - pattern = DEFAULT_CONVERSION_PATTERN; - cssBuilder = new DefaultCssBuilder(); - } - - @Override - protected Map getDefaultConverterMap() { - return PatternLayout.defaultConverterMap; - } - - @Override - public String doLayout(IAccessEvent event) { - StringBuilder buf = new StringBuilder(); - startNewTableIfLimitReached(buf); - - boolean odd = true; - if (((counter++) & 1) == 0) { - odd = false; - } - - buf.append(LINE_SEPARATOR); - buf.append(""); - } else { - buf.append(" even\">"); - } - buf.append(LINE_SEPARATOR); - - Converter c = head; - while (c != null) { - appendEventToBuffer(buf, c, event); - c = c.getNext(); - } - buf.append(""); - buf.append(LINE_SEPARATOR); - - return buf.toString(); - } - - private void appendEventToBuffer(StringBuilder buf, Converter c, IAccessEvent event) { - buf.append(""); - c.write(buf, event); - buf.append(""); - buf.append(LINE_SEPARATOR); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/html/UrlCssBuilder.java b/logback-access/src/main/java/ch/qos/logback/access/html/UrlCssBuilder.java deleted file mode 100644 index 87c8ce8509..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/html/UrlCssBuilder.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.html; - -import ch.qos.logback.core.html.CssBuilder; - -/** - * This class helps the HTMLLayout build the CSS link. It either provides the - * HTMLLayout with a default css file, or builds the link to an external, - * user-specified, file. - * - * @author Sébastien Pennec - */ -public class UrlCssBuilder implements CssBuilder { - - String url = "http://logback.qos.ch/css/access.css"; - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - @Override - public void addCss(StringBuilder sbuf) { - sbuf.append(""); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/html/package.html b/logback-access/src/main/java/ch/qos/logback/access/html/package.html deleted file mode 100644 index c988c3f19e..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/html/package.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - -

Contains classes to format log output in HTML.

- - - \ No newline at end of file diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyModernServerAdapter.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyModernServerAdapter.java deleted file mode 100644 index 58971ee565..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyModernServerAdapter.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - *

- * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - *

- * or (per the licensee's choosing) - *

- * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.jetty; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import ch.qos.logback.access.spi.ServerAdapter; -import org.eclipse.jetty.http.HttpField; -import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.server.Response; - -/** - * A Jetty 9.4.x and 10.0.x specific implementation of the {@link ServerAdapter} interface. - * - * @author Sébastien Pennec - * @author Ceki Gulcu - * @author Joakim Erdfelt - */ -public class JettyModernServerAdapter extends JettyServerAdapter { - - - public JettyModernServerAdapter(Request jettyRequest, Response jettyResponse) { - super(jettyRequest, jettyResponse); - } - - @Override - public long getContentLength() { - return response.getHttpChannel().getBytesWritten(); - } - - @Override - public int getStatusCode() { - return response.getCommittedMetaData().getStatus(); - } - - @Override - public long getRequestTimestamp() { - return request.getTimeStamp(); - } - - @Override - public Map buildResponseHeaderMap() { - Map responseHeaderMap = new HashMap(); - Iterator httpFieldIter = response.getHttpFields().iterator(); - while (httpFieldIter.hasNext()) { - HttpField httpField = httpFieldIter.next(); - String key = httpField.getName(); - String value = httpField.getValue(); - responseHeaderMap.put(key, value); - } - return responseHeaderMap; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java deleted file mode 100644 index bff6da05b2..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.jetty; - -import ch.qos.logback.access.spi.ServerAdapter; - -import org.eclipse.jetty.http.HttpFields; -import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.server.Response; - -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - -/** - * A jetty specific implementation of the {@link ServerAdapter} interface. - * - * @author Sébastien Pennec - * @author Ceki Gulcu - */ -public class JettyServerAdapter implements ServerAdapter { - - Request request; - Response response; - - public JettyServerAdapter(Request jettyRequest, Response jettyResponse) { - this.request = jettyRequest; - this.response = jettyResponse; - } - - @Override - public long getContentLength() { - return response.getContentCount(); - } - - @Override - public int getStatusCode() { - return response.getStatus(); - } - - @Override - public long getRequestTimestamp() { - return request.getTimeStamp(); - } - - @Override - public Map buildResponseHeaderMap() { - Map responseHeaderMap = new HashMap(); - HttpFields httpFields = response.getHttpFields(); - Enumeration e = httpFields.getFieldNames(); - while (e.hasMoreElements()) { - String key = (String) e.nextElement(); - String value = response.getHeader(key); - responseHeaderMap.put(key, value); - } - return responseHeaderMap; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java deleted file mode 100644 index 0c36aa9e61..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java +++ /dev/null @@ -1,473 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - *

- * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - *

- * or (per the licensee's choosing) - *

- * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.jetty; - -import java.io.File; -import java.net.URL; -import java.util.EventListener; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import ch.qos.logback.access.joran.JoranConfigurator; -import ch.qos.logback.access.spi.AccessEvent; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.Appender; -import ch.qos.logback.core.ContextBase; -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.boolex.EventEvaluator; -import ch.qos.logback.core.filter.Filter; -import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.spi.AppenderAttachable; -import ch.qos.logback.core.spi.AppenderAttachableImpl; -import ch.qos.logback.core.spi.FilterAttachable; -import ch.qos.logback.core.spi.FilterAttachableImpl; -import ch.qos.logback.core.spi.FilterReply; -import ch.qos.logback.core.status.ErrorStatus; -import ch.qos.logback.core.status.InfoStatus; -import ch.qos.logback.core.util.EnvUtil; -import ch.qos.logback.core.util.FileUtil; -import ch.qos.logback.core.util.OptionHelper; -import ch.qos.logback.core.util.StatusPrinter; -import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.server.RequestLog; -import org.eclipse.jetty.server.Response; -import org.eclipse.jetty.util.component.LifeCycle; - -/** - * This class is logback's implementation of jetty's RequestLog interface. - *

- * It can be seen as logback classic's LoggerContext. Appenders can be attached - * directly to RequestLogImpl and RequestLogImpl uses the same StatusManager as - * LoggerContext does. It also provides containers for properties. - * - *

- *

Supported Jetty Versions

- *

- * This {@code RequestLogImpl} only supports Jetty 7.0.0 through Jetty 10. - * If you are using Jetty 11 with the new Jakarta Servlets (namespace {@code jakarta.servlet}) - * then you will need a more modern version of {@code logback-access}. - *

- *

Configuring for Jetty 9.4.x through to Jetty 10.0.x

- *

- * Jetty 9.4.x and Jetty 10.x use a modern {@code org.eclipse.jetty.server.Server.setRequestLog(RequestLog)} - * interface that is based on a Server level RequestLog behavior. This means all requests are logged, - * even bad requests, and context-less requests. - *

- *

- * The internals of the Jetty Request and Response objects track the state of the object at the time - * they are committed (the actual state during the application when an action on the network commits the - * request/response exchange). This prevents behaviors from 3rd party libraries - * that change the state of the request / response before the RequestLog gets a chance - * to log the details. This differs from Jetty 9.3.x and - * older in that those versions used a (now deprecated) {@code RequestLogHandler} and - * would never see bad requests, or context-less requests, - * and if a 3rd party library modifies the the response (for example by setting - * {@code response.setStatus(200)} after the response has been initiated on the network) - * this change in status would be logged, instead of the actual status that was sent. - *

- *

- * First, you must be using the proper {@code ${jetty.home}} and {@code ${jetty.base}} - * directory split. Configure your {@code ${jetty.base}} with at least the `resources` module - * enabled (so that your configuration can be found). - *

- *

- * Next, create a {@code ${jetty.base}/etc/logback-access.xml} file with the following - * content. - *

- *
- *   <?xml version="1.0"?>
- *   <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
- *
- *   <Configure id="Server" class="org.eclipse.jetty.server.Server">
- *     <Set name="requestLog">
- *       <New id="LogbackAccess" class="ch.qos.logback.access.jetty.RequestLogImpl">
- *         <Set name="resource">logback-access.xml</Set>
- *       </New>
- *     </Set>
- *   </Configure>
- * - *

- * Now you'll need a {@code ${jetty.base}/resources/logback-access.xml} configuration file. - *

- * - *

- * By default, {@code RequestLogImpl} looks for a logback configuration file called - * {@code etc/logback-access.xml}, in the {@code ${jetty.base}} directory, then - * the older {@code ${jetty.home}} directory. - *

- *

- * The {@code logback-access.xml} file is slightly - * different than the usual logback classic configuration file. Most of it is - * the same: {@link Appender Appenders} and {@link ch.qos.logback.core.Layout layouts} - * are declared the exact same way. However, - * loggers elements are not allowed. - *

- * - *

It is possible to place the logback configuration file anywhere, as long as it's path is specified. - * Here is another example, with an arbitrary path to the logback-access.xml file. - *

- * - *

- *   <?xml version="1.0"?>
- *   <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
- *
- *   <Configure id="Server" class="org.eclipse.jetty.server.Server">
- *     <Set name="requestLog">
- *       <New id="LogbackAccess" class="ch.qos.logback.access.jetty.RequestLogImpl">
- *         <Set name="fileName">/arbitrary/path/to/logback-access.xml</Set>
- *       </New>
- *     </Set>
- *   </Configure>
- * 
- *

Configuring for Jetty 7.x thru to Jetty 9.3.x

- *

- * To configure these older Jetty instances to use {@code RequestLogImpl}, - * the use of the {@code RequestLogHandler} is the technique available to you. - * Modify your {@code etc/jetty-requestlog.xml} - *

- * - *
- *   <?xml version="1.0"?>
- *   <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
- *
- *   <Configure id="Server" class="org.eclipse.jetty.server.Server">
- *     <Ref id="Handlers">
- *       <Call name="addHandler">
- *         <Arg>
- *           <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
- *             <Set name="requestLog">
- *               <New id="RequestLogImpl" class="ch.qos.logback.access.jetty.RequestLogImpl"/>
- *             </Set>
- *           </New>
- *         </Arg>
- *       </Call>
- *     </Ref>
- *   </Configure>
- * 
- * - *

By default, RequestLogImpl looks for a logback configuration file called - * logback-access.xml, in the same folder where jetty.xml is located, that is - * etc/logback-access.xml. The logback-access.xml file is slightly - * different from the usual logback classic configuration file. Most of it is - * the same: Appenders and Layouts are declared the exact same way. However, - * loggers elements are not allowed. - *

- * - *

- * It is possible to put the logback configuration file anywhere, as long as - * it's path is specified. Here is another example, with a path to the - * logback-access.xml file. - *

- * - *

- *   <?xml version="1.0"?>
- *   <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
- *
- *   <Configure id="Server" class="org.eclipse.jetty.server.Server">
- *     <Ref id="Handlers">
- *       <Call name="addHandler">
- *         <Arg>
- *           <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
- *             <Set name="requestLog">
- *               <New id="RequestLogImpl" class="ch.qos.logback.access.jetty.RequestLogImpl">
- *                 <Set name="fileName">path/to/logback-access.xml</Set>
- *               </New>
- *             </Set>
- *           </New>
- *         </Arg>
- *       </Call>
- *     </Ref>
- *   </Configure>
- * 
- *

- * Next is a sample logback-access.xml file printing access events on the console. - *

- * - *

- *    <configuration>
- *      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- *        <layout class="ch.qos.logback.access.PatternLayout">
- *          <param name="Pattern" value="%date %server %remoteIP %clientHost %user %requestURL" />
- *        </layout>
- *      </appender>
- *
- *      <appender-ref ref="STDOUT" />
- *    </configuration>
- * 
- *

- * Here is another configuration file, using SMTPAppender: - *

- * - *

- *    <configuration>
- *      <appender name="SMTP" class="ch.qos.logback.access.net.SMTPAppender">
- *        <layout class="ch.qos.logback.access.PatternLayout">
- *          <param name="pattern" value="%remoteIP [%date] %requestURL %statusCode %bytesSent" />
- *        </layout>
- *        <param name="From" value="sender@domaine.org" />
- *        <param name="SMTPHost" value="mail.domain.org" />
- *         <param name="Subject" value="Last Event: %statusCode %requestURL" />
- *         <param name="To" value="server_admin@domain.org" />
- *      </appender>
- *      <appender-ref ref="SMTP" />
- *    </configuration>
- * 
- * - * @author Ceki Gülcü - * @author Sébastien Pennec - * @author Joakim Erdfelt - */ -public class RequestLogImpl extends ContextBase implements org.eclipse.jetty.util.component.LifeCycle, RequestLog, AppenderAttachable, FilterAttachable { - - public final static String DEFAULT_CONFIG_FILE = "etc" + File.separatorChar + "logback-access.xml"; - - enum State { - FAILED, STOPPED, STARTING, STARTED, STOPPING - } - - State state = State.STOPPED; - - AppenderAttachableImpl aai = new AppenderAttachableImpl(); - FilterAttachableImpl fai = new FilterAttachableImpl(); - String fileName; - String resource; - - boolean quiet = false; - - public RequestLogImpl() { - putObject(CoreConstants.EVALUATOR_MAP, new HashMap>()); - } - - @Override - public void log(Request jettyRequest, Response jettyResponse) { - JettyServerAdapter adapter = makeJettyServerAdapter(jettyRequest, jettyResponse); - IAccessEvent accessEvent = new AccessEvent(this, jettyRequest, jettyResponse, adapter); - if (getFilterChainDecision(accessEvent) == FilterReply.DENY) { - return; - } - aai.appendLoopOnAppenders(accessEvent); - } - - private JettyServerAdapter makeJettyServerAdapter(Request jettyRequest, Response jettyResponse) { - return new JettyModernServerAdapter(jettyRequest, jettyResponse); - } - - protected void addInfo(String msg) { - getStatusManager().add(new InfoStatus(msg, this)); - } - - private void addError(String msg) { - getStatusManager().add(new ErrorStatus(msg, this)); - } - - @Override - public void start() { - state = State.STARTING; - try { - configure(); - if (!isQuiet()) { - StatusPrinter.print(getStatusManager()); - } - state = State.STARTED; - } catch (Throwable t) { - t.printStackTrace(); - state = State.FAILED; - } - } - - protected void configure() { - URL configURL = getConfigurationFileURL(); - if (configURL != null) { - runJoranOnFile(configURL); - } else { - addError("Could not find configuration file for logback-access"); - } - } - - protected URL getConfigurationFileURL() { - if (fileName != null) { - addInfo("Will use configuration file [" + fileName + "]"); - File file = new File(fileName); - if (!file.exists()) return null; - return FileUtil.fileToURL(file); - } - if (resource != null) { - addInfo("Will use configuration resource [" + resource + "]"); - return this.getClass().getResource(resource); - } - - String defaultConfigFile = DEFAULT_CONFIG_FILE; - // Always attempt ${jetty.base} first - String jettyBaseProperty = OptionHelper.getSystemProperty("jetty.base"); - if (!OptionHelper.isNullOrEmpty(jettyBaseProperty)) { - defaultConfigFile = jettyBaseProperty + File.separatorChar + DEFAULT_CONFIG_FILE; - } - - File file = new File(defaultConfigFile); - if (!file.exists()) { - // Then use ${jetty.home} (not supported in Jetty 10+) - String jettyHomeProperty = OptionHelper.getSystemProperty("jetty.home"); - if (!OptionHelper.isEmpty(jettyHomeProperty)) { - defaultConfigFile = jettyHomeProperty + File.separatorChar + DEFAULT_CONFIG_FILE; - } else { - addInfo("Neither [jetty.base] nor [jetty.home] system properties are set."); - } - } - - file = new File(defaultConfigFile); - addInfo("Assuming default configuration file [" + defaultConfigFile + "]"); - if (!file.exists()) return null; - return FileUtil.fileToURL(file); - } - - private void runJoranOnFile(URL configURL) { - try { - JoranConfigurator jc = new JoranConfigurator(); - jc.setContext(this); - jc.doConfigure(configURL); - if (getName() == null) { - setName("LogbackRequestLog"); - } - } catch (JoranException e) { - // errors have been registered as status messages - } - } - - @Override - public void stop() { - state = State.STOPPING; - aai.detachAndStopAllAppenders(); - state = State.STOPPED; - } - - @Override - public boolean isRunning() { - return state == State.STARTED; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public void setResource(String resource) { - this.resource = resource; - } - - @Override - public boolean isStarted() { - return state == State.STARTED; - } - - @Override - public boolean isStarting() { - return state == State.STARTING; - } - - @Override - public boolean isStopping() { - return state == State.STOPPING; - } - - public boolean isStopped() { - return state == State.STOPPED; - } - - @Override - public boolean isFailed() { - return state == State.FAILED; - } - - @Override - public boolean addEventListener(EventListener listener) { - return false; - } - - @Override - public boolean removeEventListener(EventListener listener) { - return false; - } - - - public boolean isQuiet() { - return quiet; - } - - public void setQuiet(boolean quiet) { - this.quiet = quiet; - } - - @Override - public void addAppender(Appender newAppender) { - aai.addAppender(newAppender); - } - - @Override - public Iterator> iteratorForAppenders() { - return aai.iteratorForAppenders(); - } - - @Override - public Appender getAppender(String name) { - return aai.getAppender(name); - } - - @Override - public boolean isAttached(Appender appender) { - return aai.isAttached(appender); - } - - @Override - public void detachAndStopAllAppenders() { - aai.detachAndStopAllAppenders(); - } - - @Override - public boolean detachAppender(Appender appender) { - return aai.detachAppender(appender); - } - - @Override - public boolean detachAppender(String name) { - return aai.detachAppender(name); - } - - @Override - public void addFilter(Filter newFilter) { - fai.addFilter(newFilter); - } - - @Override - public void clearAllFilters() { - fai.clearAllFilters(); - } - - @Override - public List> getCopyOfAttachedFiltersList() { - return fai.getCopyOfAttachedFiltersList(); - } - - @Override - public FilterReply getFilterChainDecision(IAccessEvent event) { - return fai.getFilterChainDecision(event); - } - - public void addLifeCycleListener(LifeCycle.Listener listener) { - // we'll implement this when asked - } - - public void removeLifeCycleListener(LifeCycle.Listener listener) { - // we'll implement this when asked - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java deleted file mode 100644 index acdf91dfa8..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.jetty; - -import java.util.HashMap; -import java.util.Map; - -// this class is currently not used -public class RequestLogRegistry { - - private static Map requestLogRegistry = new HashMap(); - - public static void register(RequestLogImpl requestLogImpl) { - requestLogRegistry.put(requestLogImpl.getName(), requestLogImpl); - } - - public static RequestLogImpl get(String key) { - return requestLogRegistry.get(key); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/package.html b/logback-access/src/main/java/ch/qos/logback/access/jetty/package.html deleted file mode 100644 index bc2c3dc595..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/jetty/package.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - -

This is logback access' implementation for Jetty 8.

- - - \ No newline at end of file diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java b/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java deleted file mode 100644 index 8bfb94850d..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2022, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.joran; - -import ch.qos.logback.access.joran.action.ConfigurationAction; -import ch.qos.logback.access.model.processor.LogbackAccessDefaultNestedComponentRegistryRules; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.joran.JoranConfiguratorBase; -import ch.qos.logback.core.joran.action.AppenderRefAction; -import ch.qos.logback.core.joran.action.IncludeAction; -import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry; -import ch.qos.logback.core.joran.spi.ElementSelector; -import ch.qos.logback.core.joran.spi.RuleStore; -import ch.qos.logback.core.model.processor.DefaultProcessor; - -/** - * This JoranConfiguratorclass adds rules specific to logback-access. - * - * @author Ceki Gülcü - */ -public class JoranConfigurator extends JoranConfiguratorBase { - - @Override - public void addElementSelectorAndActionAssociations(RuleStore rs) { - super.addElementSelectorAndActionAssociations(rs); - - rs.addRule(new ElementSelector("configuration"), () -> new ConfigurationAction()); - rs.addRule(new ElementSelector("configuration/appender-ref"), () -> new AppenderRefAction()); - rs.addRule(new ElementSelector("configuration/include"), () -> new IncludeAction()); - } - - @Override - protected void addModelHandlerAssociations(DefaultProcessor defaultProcessor) { - - ModelClassToModelHandlerLinker mham = new ModelClassToModelHandlerLinker(context); - mham.link(defaultProcessor); - - } - - - @Override - protected void addDefaultNestedComponentRegistryRules(DefaultNestedComponentRegistry registry) { - LogbackAccessDefaultNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/ModelClassToModelHandlerLinker.java b/logback-access/src/main/java/ch/qos/logback/access/joran/ModelClassToModelHandlerLinker.java deleted file mode 100644 index 11fbcd409d..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/joran/ModelClassToModelHandlerLinker.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2023, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ - -package ch.qos.logback.access.joran; - -import ch.qos.logback.access.model.ConfigurationModel; -import ch.qos.logback.access.model.processor.ConfigurationModelHandler; -import ch.qos.logback.core.Context; -import ch.qos.logback.core.joran.ModelClassToModelHandlerLinkerBase; -import ch.qos.logback.core.model.AppenderModel; -import ch.qos.logback.core.model.AppenderRefModel; -import ch.qos.logback.core.model.processor.AppenderModelHandler; -import ch.qos.logback.core.model.processor.AppenderRefDependencyAnalyser; -import ch.qos.logback.core.model.processor.AppenderRefModelHandler; -import ch.qos.logback.core.model.processor.DefaultProcessor; -import ch.qos.logback.core.model.processor.RefContainerDependencyAnalyser; - -/** - * For a given DefaultProcessor instance link a {@link ch.qos.logback.core.model.Model Model} class to a - * {@link ch.qos.logback.core.model.processor.ModelHandlerBase ModelHandler} instance - * for logback-access. - * - *

Will also use links from super class.

- * - * @since 1.3.9/1.4.9 - */ -public class ModelClassToModelHandlerLinker extends ModelClassToModelHandlerLinkerBase { - - public ModelClassToModelHandlerLinker(Context context) { - super(context); - } - - public void link(DefaultProcessor defaultProcessor) { - super.link(defaultProcessor); - defaultProcessor.addHandler(ConfigurationModel.class, ConfigurationModelHandler::makeInstance); - defaultProcessor.addHandler(AppenderModel.class, AppenderModelHandler::makeInstance); - defaultProcessor.addHandler(AppenderRefModel.class, AppenderRefModelHandler::makeInstance); - - defaultProcessor.addAnalyser(AppenderModel.class, - () -> new RefContainerDependencyAnalyser(context, AppenderModel.class)); - defaultProcessor.addAnalyser(AppenderRefModel.class, () -> new AppenderRefDependencyAnalyser(context)); - - sealModelFilters(defaultProcessor); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/action/AccessEvaluatorAction.java b/logback-access/src/main/java/ch/qos/logback/access/joran/action/AccessEvaluatorAction.java deleted file mode 100644 index 191c2a3b86..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/joran/action/AccessEvaluatorAction.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.joran.action; - -import ch.qos.logback.access.boolex.JaninoEventEvaluator; -import ch.qos.logback.core.joran.action.EventEvaluatorAction; - -public class AccessEvaluatorAction extends EventEvaluatorAction { - - protected String defaultClassName() { - return JaninoEventEvaluator.class.getName(); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java b/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java deleted file mode 100644 index 6eb4ef794e..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.joran.action; - -import org.xml.sax.Attributes; - -import ch.qos.logback.access.model.ConfigurationModel; -import ch.qos.logback.core.joran.action.BaseModelAction; -import ch.qos.logback.core.joran.spi.SaxEventInterpretationContext; -import ch.qos.logback.core.model.Model; - -public class ConfigurationAction extends BaseModelAction { - - @Override - protected Model buildCurrentModel(SaxEventInterpretationContext interpretationContext, String name, - Attributes attributes) { - ConfigurationModel configurationModel = new ConfigurationModel(); - configurationModel.setDebug(attributes.getValue(ConfigurationModel.INTERNAL_DEBUG_ATTR)); - return configurationModel; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/package.html b/logback-access/src/main/java/ch/qos/logback/access/joran/package.html deleted file mode 100644 index 2ecf0cc362..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/joran/package.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - -

Contains the Joran configuration classes

- - - diff --git a/logback-access/src/main/java/ch/qos/logback/access/model/ConfigurationModel.java b/logback-access/src/main/java/ch/qos/logback/access/model/ConfigurationModel.java deleted file mode 100755 index 365e066f51..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/model/ConfigurationModel.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2022, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.model; - -import java.util.Objects; - -import ch.qos.logback.core.model.Model; - -public class ConfigurationModel extends Model { - - private static final long serialVersionUID = 5447825021342728679L; - - public static final String INTERNAL_DEBUG_ATTR = "debug"; - - String debug; - - @Override - protected ConfigurationModel makeNewInstance() { - return new ConfigurationModel(); - } - - @Override - protected void mirror(Model that) { - ConfigurationModel actual = (ConfigurationModel) that; - super.mirror(actual); - this.debug = actual.debug; - } - - - public String getDebug() { - return debug; - } - - public void setDebug(String debug) { - this.debug = debug; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + Objects.hash(debug); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - ConfigurationModel other = (ConfigurationModel) obj; - return Objects.equals(debug, other.debug); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/model/processor/ConfigurationModelHandler.java b/logback-access/src/main/java/ch/qos/logback/access/model/processor/ConfigurationModelHandler.java deleted file mode 100755 index 115150c88b..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/model/processor/ConfigurationModelHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2022, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.model.processor; - -import ch.qos.logback.access.model.ConfigurationModel; -import ch.qos.logback.core.Context; -import ch.qos.logback.core.model.Model; -import ch.qos.logback.core.model.processor.ModelHandlerBase; -import ch.qos.logback.core.model.processor.ModelHandlerException; -import ch.qos.logback.core.model.processor.ModelInterpretationContext; -import ch.qos.logback.core.status.OnConsoleStatusListener; -import ch.qos.logback.core.util.OptionHelper; -import ch.qos.logback.core.util.StatusListenerConfigHelper; - -public class ConfigurationModelHandler extends ModelHandlerBase { - static final String DEBUG_SYSTEM_PROPERTY_KEY = "logback-access.debug"; - - public ConfigurationModelHandler(Context context) { - super(context); - } - - static public ModelHandlerBase makeInstance(Context context, ModelInterpretationContext ic) { - return new ConfigurationModelHandler(context); - } - - protected Class getSupportedModelClass() { - return ConfigurationModel.class; - } - - @Override - public void handle(ModelInterpretationContext mic, Model model) throws ModelHandlerException { - ConfigurationModel configurationModel = (ConfigurationModel) model; - // See LBCLASSIC-225 (the system property is looked up first). Thus, it overrides - // the equivalent property in the config file. This reversal of scope priority - // is justified - // by the use case: the admin trying to chase rogue config file - String debug = System.getProperty(DEBUG_SYSTEM_PROPERTY_KEY); - if (debug == null) { - debug = configurationModel.getDebug(); - } - if (OptionHelper.isNullOrEmpty(debug) || debug.equals("false") || debug.equals("null")) { - addInfo(ConfigurationModel.INTERNAL_DEBUG_ATTR + " attribute not set"); - } else { - StatusListenerConfigHelper.addOnConsoleListenerInstance(context, new OnConsoleStatusListener()); - } - - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/model/processor/LogbackAccessDefaultNestedComponentRegistryRules.java b/logback-access/src/main/java/ch/qos/logback/access/model/processor/LogbackAccessDefaultNestedComponentRegistryRules.java deleted file mode 100644 index 2f358a8bbe..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/model/processor/LogbackAccessDefaultNestedComponentRegistryRules.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.model.processor; - -import ch.qos.logback.access.PatternLayout; -import ch.qos.logback.access.PatternLayoutEncoder; -import ch.qos.logback.access.boolex.JaninoEventEvaluator; -import ch.qos.logback.core.AppenderBase; -import ch.qos.logback.core.UnsynchronizedAppenderBase; -import ch.qos.logback.core.filter.EvaluatorFilter; -import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry; -import ch.qos.logback.core.net.ssl.SSLNestedComponentRegistryRules; - -public class LogbackAccessDefaultNestedComponentRegistryRules { - - - static public void addDefaultNestedComponentRegistryRules(DefaultNestedComponentRegistry registry) { - registry.add(AppenderBase.class, "layout", PatternLayout.class); - registry.add(EvaluatorFilter.class, "evaluator", JaninoEventEvaluator.class); - - registry.add(AppenderBase.class, "encoder", PatternLayoutEncoder.class); - registry.add(UnsynchronizedAppenderBase.class, "encoder", PatternLayoutEncoder.class); - SSLNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry); - - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/AccessEventPreSerializationTransformer.java b/logback-access/src/main/java/ch/qos/logback/access/net/AccessEventPreSerializationTransformer.java deleted file mode 100644 index b75b4faeef..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/net/AccessEventPreSerializationTransformer.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net; - -import java.io.Serializable; - -import ch.qos.logback.access.spi.AccessEvent; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.spi.PreSerializationTransformer; - -public class AccessEventPreSerializationTransformer implements PreSerializationTransformer { - - @Override - public Serializable transform(IAccessEvent event) { - if (event instanceof AccessEvent) { - return (AccessEvent) event; - } else { - throw new IllegalArgumentException("Unsupported type " + event.getClass().getName()); - } - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/HardenedAccessEventInputStream.java b/logback-access/src/main/java/ch/qos/logback/access/net/HardenedAccessEventInputStream.java deleted file mode 100755 index 2c4699f42f..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/net/HardenedAccessEventInputStream.java +++ /dev/null @@ -1,15 +0,0 @@ -package ch.qos.logback.access.net; - -import java.io.IOException; -import java.io.InputStream; - -import ch.qos.logback.access.spi.AccessEvent; -import ch.qos.logback.core.net.HardenedObjectInputStream; - -public class HardenedAccessEventInputStream extends HardenedObjectInputStream { - - public HardenedAccessEventInputStream(InputStream in) throws IOException { - super(in, new String[] { AccessEvent.class.getName(), String[].class.getName() }); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SMTPAppender.java b/logback-access/src/main/java/ch/qos/logback/access/net/SMTPAppender.java deleted file mode 100644 index 5700044eea..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/net/SMTPAppender.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net; - -import ch.qos.logback.access.PatternLayout; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.Layout; -import ch.qos.logback.core.boolex.EventEvaluator; -import ch.qos.logback.core.helpers.CyclicBuffer; -import ch.qos.logback.core.net.SMTPAppenderBase; - -/** - * Send an e-mail when a specific access event occurs, typically when certain - * pages are accessed. - * - * For more information about this appender, please refer to the online manual - * at http://logback.qos.ch/manual/appenders.html#AccessSMTPAppender - *

- * - * @author Ceki Gülcü - * @author Sébastien Pennec - * - */ -public class SMTPAppender extends SMTPAppenderBase { - - static final String DEFAULT_SUBJECT_PATTERN = "%m"; - - /** - * The default constructor will instantiate the appender with a - * {@link EventEvaluator} that will trigger on events with level ERROR or - * higher. - */ - public SMTPAppender() { - } - - /** - * Use evaluator passed as parameter as the {@link EventEvaluator} - * for this SMTPAppender. - */ - public SMTPAppender(EventEvaluator evaluator) { - this.eventEvaluator = evaluator; - } - - /** - * Perform SMTPAppender specific appending actions, mainly adding the event to - * the appropriate cyclic buffer. - */ - @Override - protected void subAppend(CyclicBuffer cb, IAccessEvent event) { - cb.add(event); - } - - @Override - protected void fillBuffer(CyclicBuffer cb, StringBuffer sbuf) { - int len = cb.length(); - for (int i = 0; i < len; i++) { - // sbuf.append(MimeUtility.encodeText(layout.format(cb.getOrCreate()))); - IAccessEvent event = cb.get(); - sbuf.append(layout.doLayout(event)); - } - } - - @Override - protected Layout makeSubjectLayout(String subjectStr) { - if (subjectStr == null) { - subjectStr = DEFAULT_SUBJECT_PATTERN; - } - PatternLayout pl = new PatternLayout(); - pl.setPattern(subjectStr); - pl.start(); - return pl; - } - - @Override - protected PatternLayout makeNewToPatternLayout(String toPattern) { - PatternLayout pl = new PatternLayout(); - pl.setPattern(toPattern); - return pl; - } - - @Override - protected boolean eventMarksEndOfLife(IAccessEvent eventObject) { - return false; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SSLSocketAppender.java b/logback-access/src/main/java/ch/qos/logback/access/net/SSLSocketAppender.java deleted file mode 100644 index 4107c93728..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/net/SSLSocketAppender.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.net.AbstractSSLSocketAppender; -import ch.qos.logback.core.spi.PreSerializationTransformer; - -/** - * A {@link SocketAppender} that supports SSL. - *

- * For more information on this appender, please refer to the online manual at - * http://logback.qos.ch/manual/appenders.html#SSLSocketAppender - * - * @author Carl Harris - */ -public class SSLSocketAppender extends AbstractSSLSocketAppender { - - private final PreSerializationTransformer pst = new AccessEventPreSerializationTransformer(); - - public SSLSocketAppender() { - } - - @Override - protected void postProcessEvent(IAccessEvent event) { - event.prepareForDeferredProcessing(); - } - - public PreSerializationTransformer getPST() { - return pst; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SimpleSocketServer.java b/logback-access/src/main/java/ch/qos/logback/access/net/SimpleSocketServer.java deleted file mode 100644 index 3360e84341..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/net/SimpleSocketServer.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net; - -import java.net.ServerSocket; -import java.net.Socket; - -import ch.qos.logback.access.joran.JoranConfigurator; -import ch.qos.logback.access.spi.AccessContext; -import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.util.StatusPrinter; - -/** - * A simple {@link SocketNode} based server. - * - *

- *     <b>Usage:</b> java ch.qos.logback.access.net.SimpleSocketServer port configFile
- *    
- *     where
- * 
- * port
- * 
- *     is a part number where the server listens and
- * 
- * configFile
- * 
- *     is an xml configuration file fed to {@link JoranConfigurator}.
- * 
- * - * @author Ceki Gülcü - * @author Sébastien Pennec - * - * @since 0.8.4 - */ -public class SimpleSocketServer { - - static int port; - - private static AccessContext basicContext; - - public static void main(String argv[]) throws Exception { - if (argv.length == 2) { - init(argv[0], argv[1]); - } else { - usage("Wrong number of arguments."); - } - - runServer(); - } - - static void runServer() { - try { - System.out.println("Listening on port " + port); - @SuppressWarnings("resource") - ServerSocket serverSocket = new ServerSocket(port); - while (true) { - System.out.println("Waiting to accept a new client."); - Socket socket = serverSocket.accept(); - System.out.println("Connected to client at " + socket.getInetAddress()); - System.out.println("Starting new socket node."); - new Thread(new SocketNode(socket, basicContext)).start(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - static void usage(String msg) { - System.err.println(msg); - System.err.println("Usage: java " + SimpleSocketServer.class.getName() + " port configFile"); - System.exit(1); - } - - static void init(String portStr, String configFile) throws JoranException { - try { - port = Integer.parseInt(portStr); - } catch (java.lang.NumberFormatException e) { - e.printStackTrace(); - usage("Could not interpret port number [" + portStr + "]."); - } - - basicContext = new AccessContext(); - if (configFile.endsWith(".xml")) { - JoranConfigurator configurator = new JoranConfigurator(); - configurator.setContext(basicContext); - configurator.doConfigure(configFile); - StatusPrinter.print(basicContext); - } - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SocketAppender.java b/logback-access/src/main/java/ch/qos/logback/access/net/SocketAppender.java deleted file mode 100644 index 38bed9cc72..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/net/SocketAppender.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -// Contributors: Dan MacDonald -package ch.qos.logback.access.net; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.net.AbstractSocketAppender; -import ch.qos.logback.core.spi.PreSerializationTransformer; - -/** - * Sends {@link IAccessEvent} objects to a remote a log server, usually a - * {@link SocketNode}. - * - * For more information about this appender, please refer to the online manual - * at http://logback.qos.ch/manual/appenders.html#AccessSocketAppender - * - * @author Ceki Gülcü - * @author Sébastien Pennec - * - */ - -public class SocketAppender extends AbstractSocketAppender { - - PreSerializationTransformer pst = new AccessEventPreSerializationTransformer(); - - public SocketAppender() { - } - - @Override - protected void postProcessEvent(IAccessEvent event) { - event.prepareForDeferredProcessing(); - } - - public PreSerializationTransformer getPST() { - return pst; - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java b/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java deleted file mode 100644 index 6b9cfdb51b..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.net.Socket; - -import ch.qos.logback.access.spi.AccessContext; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.spi.FilterReply; - -// Contributors: Moses Hohman - -/** - * Read {@link IAccessEvent} objects sent from a remote client using Sockets - * (TCP). These logging events are logged according to local policy, as if they - * were generated locally. - * - *

- * For example, the socket node might decide to log events to a local file and - * also resent them to a second socket node. - * - * @author Ceki Gülcü - * @author Sébastien Pennec - * - * @since 0.8.4 - */ -public class SocketNode implements Runnable { - - Socket socket; - AccessContext context; - HardenedAccessEventInputStream hardenedOIS; - - public SocketNode(Socket socket, AccessContext context) { - this.socket = socket; - this.context = context; - try { - hardenedOIS = new HardenedAccessEventInputStream(new BufferedInputStream(socket.getInputStream())); - } catch (Exception e) { - System.out.println("Could not open HardenedObjectInputStream to " + socket + e); - } - } - - @Override - public void run() { - IAccessEvent event; - - try { - while (true) { - // read an event from the wire - event = (IAccessEvent) hardenedOIS.readObject(); - // check that the event should be logged - if (context.getFilterChainDecision(event) == FilterReply.DENY) { - break; - } - // send it to the appenders - context.callAppenders(event); - } - } catch (java.io.EOFException e) { - System.out.println("Caught java.io.EOFException closing connection."); - } catch (java.net.SocketException e) { - System.out.println("Caught java.net.SocketException closing connection."); - } catch (IOException e) { - System.out.println("Caught java.io.IOException: " + e); - System.out.println("Closing connection."); - } catch (Exception e) { - System.out.println("Unexpected exception. Closing connection." + e); - } - - try { - hardenedOIS.close(); - } catch (Exception e) { - System.out.println("Could not close connection." + e); - } - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/URLEvaluator.java b/logback-access/src/main/java/ch/qos/logback/access/net/URLEvaluator.java deleted file mode 100644 index 9abdb9b569..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/net/URLEvaluator.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net; - -import java.util.ArrayList; -import java.util.List; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.boolex.EvaluationException; -import ch.qos.logback.core.boolex.EventEvaluator; -import ch.qos.logback.core.spi.ContextAwareBase; -import ch.qos.logback.core.spi.LifeCycle; - -public class URLEvaluator extends ContextAwareBase implements EventEvaluator, LifeCycle { - - boolean started; - String name; - private List URLList = new ArrayList(); - - public void addURL(String url) { - URLList.add(url); - } - - @Override - public void start() { - if (URLList.size() == 0) { - addWarn("No URL was given to URLEvaluator"); - } else { - started = true; - } - } - - @Override - public boolean evaluate(IAccessEvent event) throws NullPointerException, EvaluationException { - String url = event.getRequestURL(); - for (String expected : URLList) { - if (url.contains(expected)) { - return true; - } - } - return false; - } - - @Override - public String getName() { - return name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @Override - public boolean isStarted() { - return started; - } - - @Override - public void stop() { - started = false; - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/server/SSLServerSocketAppender.java b/logback-access/src/main/java/ch/qos/logback/access/net/server/SSLServerSocketAppender.java deleted file mode 100644 index add845d9c7..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/net/server/SSLServerSocketAppender.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net.server; - -import ch.qos.logback.access.net.AccessEventPreSerializationTransformer; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.net.server.SSLServerSocketAppenderBase; -import ch.qos.logback.core.spi.PreSerializationTransformer; - -/** - * An appender that listens on a TCP port for connections from remote loggers. - * Each event delivered to this appender is delivered to all connected remote - * loggers. - * - * @author Carl Harris - */ -public class SSLServerSocketAppender extends SSLServerSocketAppenderBase { - - private static final PreSerializationTransformer pst = new AccessEventPreSerializationTransformer(); - - @Override - protected void postProcessEvent(IAccessEvent event) { - event.prepareForDeferredProcessing(); - } - - @Override - protected PreSerializationTransformer getPST() { - return pst; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/server/ServerSocketAppender.java b/logback-access/src/main/java/ch/qos/logback/access/net/server/ServerSocketAppender.java deleted file mode 100644 index fa9b9c58d1..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/net/server/ServerSocketAppender.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net.server; - -import ch.qos.logback.access.net.AccessEventPreSerializationTransformer; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.net.server.AbstractServerSocketAppender; -import ch.qos.logback.core.spi.PreSerializationTransformer; - -/** - * An appender that listens on a TCP port for connections from remote loggers. - * Each event delivered to this appender is delivered to all connected remote - * loggers. - * - * @author Carl Harris - */ -public class ServerSocketAppender extends AbstractServerSocketAppender { - - private static final PreSerializationTransformer pst = new AccessEventPreSerializationTransformer(); - - @Override - protected void postProcessEvent(IAccessEvent event) { - event.prepareForDeferredProcessing(); - } - - @Override - protected PreSerializationTransformer getPST() { - return pst; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/server/package.html b/logback-access/src/main/java/ch/qos/logback/access/net/server/package.html deleted file mode 100644 index 162894cfd9..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/net/server/package.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - -

Provides a robust appender that serves logging events to remote clients

-

The ServerSocketAppender - listens on a configurable TCP port for connections from remote - loggers. Events that are delivered to the appender are serialized - and sent to each connected remote logger. -

- - diff --git a/logback-access/src/main/java/ch/qos/logback/access/package.html b/logback-access/src/main/java/ch/qos/logback/access/package.html deleted file mode 100644 index 5755fc4968..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/package.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - -

This is logback access' main package.

- - - \ No newline at end of file diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/AccessConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/AccessConverter.java deleted file mode 100644 index fa5cb645d0..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/AccessConverter.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.Context; -import ch.qos.logback.core.pattern.DynamicConverter; -import ch.qos.logback.core.spi.ContextAware; -import ch.qos.logback.core.spi.ContextAwareBase; -import ch.qos.logback.core.status.Status; - -abstract public class AccessConverter extends DynamicConverter implements ContextAware { - - public final static char SPACE_CHAR = ' '; - public final static char QUESTION_CHAR = '?'; - - ContextAwareBase cab = new ContextAwareBase(); - - @Override - public void setContext(Context context) { - cab.setContext(context); - } - - @Override - public Context getContext() { - return cab.getContext(); - } - - @Override - public void addStatus(Status status) { - cab.addStatus(status); - } - - @Override - public void addInfo(String msg) { - cab.addInfo(msg); - } - - @Override - public void addInfo(String msg, Throwable ex) { - cab.addInfo(msg, ex); - } - - @Override - public void addWarn(String msg) { - cab.addWarn(msg); - } - - @Override - public void addWarn(String msg, Throwable ex) { - cab.addWarn(msg, ex); - } - - @Override - public void addError(String msg) { - cab.addError(msg); - } - - @Override - public void addError(String msg, Throwable ex) { - cab.addError(msg, ex); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/ContentLengthConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/ContentLengthConverter.java deleted file mode 100644 index c040513db2..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/ContentLengthConverter.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class ContentLengthConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - long len = accessEvent.getContentLength(); - if (len == IAccessEvent.SENTINEL) { - return IAccessEvent.NA; - } else { - return Long.toString(len); - } - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/DateConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/DateConverter.java deleted file mode 100644 index 158619f74d..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/DateConverter.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import java.time.ZoneId; -import java.util.List; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.util.CachingDateFormatter; - -public class DateConverter extends AccessConverter { - - CachingDateFormatter cachingDateFormatter = null; - - @Override - public void start() { - - String datePattern = getFirstOption(); - if (datePattern == null) { - datePattern = CoreConstants.CLF_DATE_PATTERN; - } - - if (datePattern.equals(CoreConstants.ISO8601_STR)) { - datePattern = CoreConstants.ISO8601_PATTERN; - } - ZoneId zoneId = null; - List optionList = getOptionList(); - - // if the option list contains a TZ option, then set it. - if (optionList != null && optionList.size() > 1) { - String zoneIdString = (String) optionList.get(1); - zoneId = ZoneId.of(zoneIdString); - } - - try { - cachingDateFormatter = new CachingDateFormatter(datePattern, zoneId); - // maximumCacheValidity = CachedDateFormat.getMaximumCacheValidity(pattern); - } catch (IllegalArgumentException e) { - addWarn("Could not instantiate SimpleDateFormat with pattern " + datePattern, e); - addWarn("Defaulting to " + CoreConstants.CLF_DATE_PATTERN); - cachingDateFormatter = new CachingDateFormatter(CoreConstants.CLF_DATE_PATTERN, zoneId); - } - - } - - @Override - public String convert(IAccessEvent accessEvent) { - long timestamp = accessEvent.getTimeStamp(); - return cachingDateFormatter.format(timestamp); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/ElapsedSecondsConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/ElapsedSecondsConverter.java deleted file mode 100644 index 079e3fa0a1..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/ElapsedSecondsConverter.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2013, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class ElapsedSecondsConverter extends AccessConverter { - - public String convert(IAccessEvent accessEvent) { - return Long.toString(accessEvent.getElapsedSeconds()); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/ElapsedTimeConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/ElapsedTimeConverter.java deleted file mode 100644 index 381d757e76..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/ElapsedTimeConverter.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class ElapsedTimeConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return Long.toString(accessEvent.getElapsedTime()); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/EnsureLineSeparation.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/EnsureLineSeparation.java deleted file mode 100644 index 2e415d16e5..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/EnsureLineSeparation.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.Context; -import ch.qos.logback.core.pattern.Converter; -import ch.qos.logback.core.pattern.ConverterUtil; -import ch.qos.logback.core.pattern.PostCompileProcessor; - -public class EnsureLineSeparation implements PostCompileProcessor { - - /** - * Add a line separator converter so that access event appears on a separate - * line. - */ - @Override - public void process(Context context, Converter head) { - if (head == null) - throw new IllegalArgumentException("Empty converter chain"); - - // if head != null, then tail != null as well - Converter tail = ConverterUtil.findTail(head); - Converter newLineConverter = new LineSeparatorConverter(); - if (!(tail instanceof LineSeparatorConverter)) { - tail.setNext(newLineConverter); - } - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/FullRequestConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/FullRequestConverter.java deleted file mode 100644 index 5b2c439545..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/FullRequestConverter.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import java.util.Enumeration; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.CoreConstants; - -/** - * This class is tied to the fullRequest conversion word. - *

- * It has been removed from the {@link ch.qos.logback.access.PatternLayout} - * since it needs further testing before wide use. - *

- * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ -public class FullRequestConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent ae) { - StringBuilder buf = new StringBuilder(); - buf.append(ae.getRequestURL()); - buf.append(CoreConstants.LINE_SEPARATOR); - - Enumeration headerNames = ae.getRequestHeaderNames(); - while (headerNames.hasMoreElements()) { - String name = headerNames.nextElement(); - buf.append(name); - buf.append(": "); - buf.append(ae.getRequestHeader(name)); - buf.append(CoreConstants.LINE_SEPARATOR); - } - buf.append(CoreConstants.LINE_SEPARATOR); - buf.append(ae.getRequestContent()); - return buf.toString(); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/FullResponseConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/FullResponseConverter.java deleted file mode 100644 index e0366cb118..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/FullResponseConverter.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import java.util.List; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.CoreConstants; - -public class FullResponseConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent ae) { - StringBuilder buf = new StringBuilder(); - - buf.append("HTTP/1.1 "); - int statusCode = ae.getStatusCode(); - buf.append(statusCode); - buf.append(" "); - buf.append(getStatusCodeDescription(statusCode)); - buf.append(CoreConstants.LINE_SEPARATOR); - - List hnList = ae.getResponseHeaderNameList(); - for (String headerName : hnList) { - buf.append(headerName); - buf.append(": "); - buf.append(ae.getResponseHeader(headerName)); - buf.append(CoreConstants.LINE_SEPARATOR); - } - buf.append(CoreConstants.LINE_SEPARATOR); - buf.append(ae.getResponseContent()); - buf.append(CoreConstants.LINE_SEPARATOR); - return buf.toString(); - } - - static String getStatusCodeDescription(int sc) { - switch (sc) { - case 200: - return "OK"; - case 201: - return "Created"; - case 202: - return "Accepted"; - case 203: - return "Non-Authoritative Information"; - case 204: - return "No Content"; - case 205: - return "Reset Content"; - case 206: - return "Partial Content"; - case 300: - return "Multiple Choices"; - case 301: - return "Moved Permanently"; - case 302: - return "Found"; - case 303: - return "See Other"; - case 304: - return "Not Modified"; - case 305: - return "Use Proxy"; - case 306: - return "(Unused)"; - case 307: - return "Temporary Redirect"; - case 400: - return "Bad Request"; - case 401: - return "Unauthorized"; - case 402: - return "Payment Required"; - case 403: - return "Forbidden"; - case 404: - return "Not Found"; - case 405: - return "Method Not Allowed"; - case 406: - return "Not Acceptable"; - case 407: - return "Proxy Authentication Required"; - case 408: - return "Request Timeout"; - case 409: - return "Conflict"; - case 410: - return "Gone"; - case 411: - return "Length Required"; - case 412: - return "Precondition Failed"; - case 413: - return "Request Entity Too Large"; - case 414: - return "Request-URI Too Long"; - case 415: - return "Unsupported Media Type"; - case 416: - return "Requested Range Not Satisfiable"; - case 417: - return "Expectation Failed"; - case 500: - return "Internal Server Error"; - case 501: - return "Not Implemented"; - case 502: - return "Bad Gateway"; - case 503: - return "Service Unavailable"; - case 504: - return "Gateway Timeout"; - case 505: - return "HTTP Version Not Supported"; - default: - return "NA"; - } - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/LineSeparatorConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/LineSeparatorConverter.java deleted file mode 100644 index 1590a2ab6f..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/LineSeparatorConverter.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.CoreConstants; - -public class LineSeparatorConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent event) { - return CoreConstants.LINE_SEPARATOR; - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalIPAddressConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalIPAddressConverter.java deleted file mode 100644 index 21f576acb3..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalIPAddressConverter.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class LocalIPAddressConverter extends AccessConverter { - - String localIPAddressStr; - - public LocalIPAddressConverter() { - try { - localIPAddressStr = InetAddress.getLocalHost().getHostAddress(); - } catch (UnknownHostException uhe) { - localIPAddressStr = "127.0.0.1"; - } - } - - @Override - public String convert(IAccessEvent accessEvent) { - return localIPAddressStr; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalPortConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalPortConverter.java deleted file mode 100644 index 1b0d566690..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalPortConverter.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class LocalPortConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return Integer.toString(accessEvent.getLocalPort()); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/NAConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/NAConverter.java deleted file mode 100644 index 1e4e93de8c..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/NAConverter.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -/** - * Always returns the NA (not available) string which is "-" in the case of - * access conversions. - * - * @author Ceki Gülcü - */ -public class NAConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return IAccessEvent.NA; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/QueryStringConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/QueryStringConverter.java deleted file mode 100644 index ac8633243f..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/QueryStringConverter.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2013, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class QueryStringConverter extends AccessConverter { - - public String convert(IAccessEvent accessEvent) { - return accessEvent.getQueryString(); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteHostConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteHostConverter.java deleted file mode 100644 index bad1c898cb..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteHostConverter.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class RemoteHostConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return accessEvent.getRemoteHost(); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteIPAddressConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteIPAddressConverter.java deleted file mode 100644 index 7f91702521..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteIPAddressConverter.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class RemoteIPAddressConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return accessEvent.getRemoteAddr(); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteUserConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteUserConverter.java deleted file mode 100644 index 7b0864a9e9..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteUserConverter.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class RemoteUserConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - - String user = accessEvent.getRemoteUser(); - if (user == null) { - return IAccessEvent.NA; - } else { - return user; - } - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestAttributeConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestAttributeConverter.java deleted file mode 100644 index 24b10d8714..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestAttributeConverter.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.util.OptionHelper; - -public class RequestAttributeConverter extends AccessConverter { - - String key; - - @Override - public void start() { - key = getFirstOption(); - if (OptionHelper.isNullOrEmpty(key)) { - addWarn("Missing key for the request attribute"); - } else { - super.start(); - } - } - - @Override - public String convert(IAccessEvent accessEvent) { - if (!isStarted()) { - return "INACTIVE_REQUEST_ATTRIB_CONV"; - } - - return accessEvent.getAttribute(key); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestContentConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestContentConverter.java deleted file mode 100644 index d6d9683438..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestContentConverter.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -/** - * This class is tied to the requestContent conversion word. - *

- * It has been removed from the {@link ch.qos.logback.access.PatternLayout} - * since it needs further testing before wide use. - *

- * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ -public class RequestContentConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return accessEvent.getRequestContent(); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestCookieConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestCookieConverter.java deleted file mode 100644 index ef9eb5648d..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestCookieConverter.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.util.OptionHelper; - -public class RequestCookieConverter extends AccessConverter { - - String key; - - @Override - public void start() { - key = getFirstOption(); - if (OptionHelper.isNullOrEmpty(key)) { - addWarn("Missing key for the requested header"); - } else { - super.start(); - } - } - - @Override - public String convert(IAccessEvent accessEvent) { - if (!isStarted()) { - return "INACTIVE_COOKIE_CONVERTER"; - } - - return accessEvent.getCookie(key); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestHeaderConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestHeaderConverter.java deleted file mode 100644 index 1bd5bca3a4..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestHeaderConverter.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.util.OptionHelper; - -public class RequestHeaderConverter extends AccessConverter { - - String key; - - @Override - public void start() { - key = getFirstOption(); - if (OptionHelper.isNullOrEmpty(key)) { - addWarn("Missing key for the requested header. Defaulting to all keys."); - key = null; - } - super.start(); - } - - @Override - public String convert(IAccessEvent accessEvent) { - if (!isStarted()) { - return "INACTIVE_HEADER_CONV"; - } - - if (key != null) { - return accessEvent.getRequestHeader(key); - } else { - return accessEvent.getRequestHeaderMap().toString(); - } - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestMethodConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestMethodConverter.java deleted file mode 100644 index 51b9a82b03..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestMethodConverter.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class RequestMethodConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return accessEvent.getMethod(); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestParameterConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestParameterConverter.java deleted file mode 100644 index ec621b5b90..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestParameterConverter.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import java.util.Arrays; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.util.OptionHelper; - -public class RequestParameterConverter extends AccessConverter { - - String key; - - @Override - public void start() { - key = getFirstOption(); - if (OptionHelper.isNullOrEmpty(key)) { - addWarn("Missing key for the request parameter"); - } else { - super.start(); - } - } - - @Override - public String convert(IAccessEvent accessEvent) { - if (!isStarted()) { - return "INACTIVE_REQUEST_PARAM_CONV"; - } - - String[] paramArray = accessEvent.getRequestParameter(key); - if (paramArray.length == 1) { - return paramArray[0]; - } else { - // for an array string {"a", "b"} named 'sa', Array.toString(sa) returns the - // string - // "[a, b]". - return Arrays.toString(paramArray); - } - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestProtocolConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestProtocolConverter.java deleted file mode 100644 index a20f7878b3..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestProtocolConverter.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class RequestProtocolConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return accessEvent.getProtocol(); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURIConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURIConverter.java deleted file mode 100644 index 7f8cebce05..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURIConverter.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -/** - * The request URI. - * - * @author Ceki Gülcü - */ -public class RequestURIConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return accessEvent.getRequestURI(); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURLConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURLConverter.java deleted file mode 100644 index fd50d7d4a9..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURLConverter.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -/** - * The first line of the request. - * - * @author Ceki Gülcü - */ -public class RequestURLConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return accessEvent.getRequestURL(); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseContentConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseContentConverter.java deleted file mode 100644 index 9e5ae54fcb..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseContentConverter.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -/** - * This class is tied to the requestContent conversion word. - *

- * It has been removed from the {@link ch.qos.logback.access.PatternLayout} - * since it needs further testing before wide use. - *

- * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ -public class ResponseContentConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return accessEvent.getResponseContent(); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseHeaderConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseHeaderConverter.java deleted file mode 100644 index 6d4becc384..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseHeaderConverter.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.util.OptionHelper; - -public class ResponseHeaderConverter extends AccessConverter { - - String key; - - @Override - public void start() { - key = getFirstOption(); - if (OptionHelper.isNullOrEmpty(key)) { - addWarn("Missing key for the response header"); - } else { - super.start(); - } - } - - @Override - public String convert(IAccessEvent accessEvent) { - if (!isStarted()) { - return "INACTIVE_REPONSE_HEADER_CONV"; - } - - return accessEvent.getResponseHeader(key); - // return null; - - // HttpServletResponse response = accessEvent.getHttpResponse(); - // - // Object value = null; // = response.getHeader(key); - // if (value == null) { - // return AccessConverter.NA; - // } else { - // return value.toString(); - // } - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/ServerNameConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/ServerNameConverter.java deleted file mode 100644 index 086e8179a6..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/ServerNameConverter.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class ServerNameConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return accessEvent.getServerName(); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/SessionIDConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/SessionIDConverter.java deleted file mode 100644 index 92e80083b4..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/SessionIDConverter.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2013, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class SessionIDConverter extends AccessConverter { - - public String convert(IAccessEvent accessEvent) { - return accessEvent.getSessionID(); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/StatusCodeConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/StatusCodeConverter.java deleted file mode 100644 index d19807415d..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/StatusCodeConverter.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class StatusCodeConverter extends AccessConverter { - - @Override - public String convert(IAccessEvent accessEvent) { - return Integer.toString(accessEvent.getStatusCode()); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/ThreadNameConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/ThreadNameConverter.java deleted file mode 100644 index 7c9520993c..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/ThreadNameConverter.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2013, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - -import ch.qos.logback.access.spi.IAccessEvent; - -public class ThreadNameConverter extends AccessConverter { - - public String convert(IAccessEvent accessEvent) { - return accessEvent.getThreadName(); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/package.html b/logback-access/src/main/java/ch/qos/logback/access/pattern/package.html deleted file mode 100644 index 5e4898f941..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/package.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - -

Provides classes implementing format specifiers in conversion patterns.

- - - \ No newline at end of file diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeFilter.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeFilter.java deleted file mode 100644 index ba8d5a2682..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeFilter.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.servlet; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.List; - -import jakarta.servlet.Filter; -import jakarta.servlet.FilterChain; -import jakarta.servlet.FilterConfig; -import jakarta.servlet.ServletException; -import jakarta.servlet.ServletRequest; -import jakarta.servlet.ServletResponse; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -import static ch.qos.logback.access.AccessConstants.LB_OUTPUT_BUFFER; -import static ch.qos.logback.access.AccessConstants.TEE_FILTER_INCLUDES_PARAM; -import static ch.qos.logback.access.AccessConstants.TEE_FILTER_EXCLUDES_PARAM; - -public class TeeFilter implements Filter { - - boolean active; - - @Override - public void destroy() { - // NOP - } - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) - throws IOException, ServletException { - - if (active && request instanceof HttpServletRequest) { - try { - TeeHttpServletRequest teeRequest = new TeeHttpServletRequest((HttpServletRequest) request); - TeeHttpServletResponse teeResponse = new TeeHttpServletResponse((HttpServletResponse) response); - - // System.out.println("BEFORE TeeFilter. filterChain.doFilter()"); - filterChain.doFilter(teeRequest, teeResponse); - // System.out.println("AFTER TeeFilter. filterChain.doFilter()"); - - teeResponse.finish(); - // let the output contents be available for later use by - // logback-access-logging - teeRequest.setAttribute(LB_OUTPUT_BUFFER, teeResponse.getOutputBuffer()); - } catch (IOException e) { - e.printStackTrace(); - throw e; - } catch (ServletException e) { - e.printStackTrace(); - throw e; - } - } else { - filterChain.doFilter(request, response); - } - - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - String includeListAsStr = filterConfig.getInitParameter(TEE_FILTER_INCLUDES_PARAM); - String excludeListAsStr = filterConfig.getInitParameter(TEE_FILTER_EXCLUDES_PARAM); - String localhostName = getLocalhostName(); - - active = computeActivation(localhostName, includeListAsStr, excludeListAsStr); - if (active) - System.out.println("TeeFilter will be ACTIVE on this host [" + localhostName + "]"); - else - System.out.println("TeeFilter will be DISABLED on this host [" + localhostName + "]"); - - } - - static List extractNameList(String nameListAsStr) { - List nameList = new ArrayList(); - if (nameListAsStr == null) { - return nameList; - } - - nameListAsStr = nameListAsStr.trim(); - if (nameListAsStr.length() == 0) { - return nameList; - } - - String[] nameArray = nameListAsStr.split("[,;]"); - for (String n : nameArray) { - n = n.trim(); - nameList.add(n); - } - return nameList; - } - - static String getLocalhostName() { - String hostname = "127.0.0.1"; - - try { - hostname = InetAddress.getLocalHost().getHostName(); - } catch (UnknownHostException uhe) { - uhe.printStackTrace(); - } - return hostname; - } - - static boolean computeActivation(String hostname, String includeListAsStr, String excludeListAsStr) { - List includeList = extractNameList(includeListAsStr); - List excludeList = extractNameList(excludeListAsStr); - boolean inIncludesList = mathesIncludesList(hostname, includeList); - boolean inExcludesList = mathesExcludesList(hostname, excludeList); - return inIncludesList && (!inExcludesList); - } - - static boolean mathesIncludesList(String hostname, List includeList) { - if (includeList.isEmpty()) - return true; - return includeList.contains(hostname); - } - - static boolean mathesExcludesList(String hostname, List excludesList) { - if (excludesList.isEmpty()) - return false; - return excludesList.contains(hostname); - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletRequest.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletRequest.java deleted file mode 100644 index 0abb0059f8..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletRequest.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.servlet; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -import jakarta.servlet.ServletInputStream; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletRequestWrapper; - -import static ch.qos.logback.access.AccessConstants.LB_INPUT_BUFFER; - -/** - * As the "tee" program on Unix, duplicate the request's input stream. - * - * @author Ceki Gülcü - */ -class TeeHttpServletRequest extends HttpServletRequestWrapper { - - private TeeServletInputStream inStream; - private BufferedReader reader; - boolean postedParametersMode = false; - - TeeHttpServletRequest(HttpServletRequest request) { - super(request); - // we can't access the input stream and access the request parameters - // at the same time - if (Util.isFormUrlEncoded(request)) { - postedParametersMode = true; - } else { - inStream = new TeeServletInputStream(request); - // add the contents of the input buffer as an attribute of the request - request.setAttribute(LB_INPUT_BUFFER, inStream.getInputBuffer()); - reader = new BufferedReader(new InputStreamReader(inStream)); - } - - } - - byte[] getInputBuffer() { - if (postedParametersMode) { - throw new IllegalStateException("Call disallowed in postedParametersMode"); - } - return inStream.getInputBuffer(); - } - - @Override - public ServletInputStream getInputStream() throws IOException { - if (!postedParametersMode) { - return inStream; - } else { - return super.getInputStream(); - } - } - - // - - @Override - public BufferedReader getReader() throws IOException { - if (!postedParametersMode) { - return reader; - } else { - return super.getReader(); - } - } - - public boolean isPostedParametersMode() { - return postedParametersMode; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletResponse.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletResponse.java deleted file mode 100644 index 6140a5557a..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletResponse.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.servlet; - -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; - -import jakarta.servlet.ServletOutputStream; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.servlet.http.HttpServletResponseWrapper; - -public class TeeHttpServletResponse extends HttpServletResponseWrapper { - - TeeServletOutputStream teeServletOutputStream; - PrintWriter teeWriter; - - public TeeHttpServletResponse(HttpServletResponse httpServletResponse) { - super(httpServletResponse); - } - - @Override - public ServletOutputStream getOutputStream() throws IOException { - if (teeServletOutputStream == null) { - teeServletOutputStream = new TeeServletOutputStream(this.getResponse()); - } - return teeServletOutputStream; - } - - @Override - public PrintWriter getWriter() throws IOException { - if (this.teeWriter == null) { - this.teeWriter = new PrintWriter( - new OutputStreamWriter(getOutputStream(), this.getResponse().getCharacterEncoding()), true); - } - return this.teeWriter; - } - - @Override - public void flushBuffer() { - if (this.teeWriter != null) { - this.teeWriter.flush(); - } - } - - byte[] getOutputBuffer() { - // teeServletOutputStream can be null if the getOutputStream method is never - // called. - if (teeServletOutputStream != null) { - return teeServletOutputStream.getOutputStreamAsByteArray(); - } else { - return null; - } - } - - void finish() throws IOException { - if (this.teeWriter != null) { - this.teeWriter.close(); - } - if (this.teeServletOutputStream != null) { - this.teeServletOutputStream.close(); - } - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java deleted file mode 100644 index 7c349542b8..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.servlet; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - -import jakarta.servlet.ReadListener; -import jakarta.servlet.ServletInputStream; -import jakarta.servlet.http.HttpServletRequest; - -class TeeServletInputStream extends ServletInputStream { - - InputStream in; - byte[] inputBuffer; - - TeeServletInputStream(HttpServletRequest request) { - duplicateInputStream(request); - } - - private void duplicateInputStream(HttpServletRequest request) { - ServletInputStream originalSIS = null; - try { - originalSIS = request.getInputStream(); - inputBuffer = consumeBufferAndReturnAsByteArray(originalSIS); - this.in = new ByteArrayInputStream(inputBuffer); - } catch (IOException e) { - e.printStackTrace(); - } finally { - closeStream(originalSIS); - } - } - - @Override - public int read() throws IOException { - return in.read(); - } - - byte[] consumeBufferAndReturnAsByteArray(InputStream is) throws IOException { - int len = 1024; - byte[] temp = new byte[len]; - int c = -1; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - while ((c = is.read(temp, 0, len)) != -1) { - baos.write(temp, 0, c); - } - return baos.toByteArray(); - } - - void closeStream(ServletInputStream is) { - if (is != null) { - try { - is.close(); - } catch (IOException e) { - } - } - } - - byte[] getInputBuffer() { - return inputBuffer; - } - - @Override - public boolean isFinished() { - throw new RuntimeException("Not yet implemented"); - } - - @Override - public boolean isReady() { - throw new RuntimeException("Not yet implemented"); - } - - @Override - public void setReadListener(ReadListener listener) { - throw new RuntimeException("Not yet implemented"); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java deleted file mode 100644 index ffe9fde593..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.servlet; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import jakarta.servlet.ServletOutputStream; -import jakarta.servlet.ServletResponse; -import jakarta.servlet.WriteListener; - -public class TeeServletOutputStream extends ServletOutputStream { - - final ServletOutputStream underlyingStream; - final ByteArrayOutputStream baosCopy; - - TeeServletOutputStream(ServletResponse httpServletResponse) throws IOException { - // System.out.println("TeeServletOutputStream.constructor() called"); - this.underlyingStream = httpServletResponse.getOutputStream(); - baosCopy = new ByteArrayOutputStream(); - } - - byte[] getOutputStreamAsByteArray() { - return baosCopy.toByteArray(); - } - - @Override - public void write(int val) throws IOException { - if (underlyingStream != null) { - underlyingStream.write(val); - baosCopy.write(val); - } - } - - @Override - public void write(byte[] byteArray) throws IOException { - if (underlyingStream == null) { - return; - } - // System.out.println("WRITE TeeServletOutputStream.write(byte[]) called"); - write(byteArray, 0, byteArray.length); - } - - @Override - public void write(byte byteArray[], int offset, int length) throws IOException { - if (underlyingStream == null) { - return; - } - // System.out.println("WRITE TeeServletOutputStream.write(byte[], int, int) - // called"); - // System.out.println(new String(byteArray, offset, length)); - underlyingStream.write(byteArray, offset, length); - baosCopy.write(byteArray, offset, length); - } - - @Override - public void close() throws IOException { - // System.out.println("CLOSE TeeServletOutputStream.close() called"); - - // If the servlet accessing the stream is using a writer instead of - // an OutputStream, it will probably call os.close() before calling - // writer.close. Thus, the underlying output stream will be called - // before the data sent to the writer could be flushed. - } - - @Override - public void flush() throws IOException { - if (underlyingStream == null) { - return; - } - // System.out.println("FLUSH TeeServletOutputStream.flush() called"); - underlyingStream.flush(); - baosCopy.flush(); - } - - @Override - public boolean isReady() { - throw new RuntimeException("Not yet implemented"); - } - - @Override - public void setWriteListener(WriteListener listener) { - throw new RuntimeException("Not yet implemented"); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/Util.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/Util.java deleted file mode 100755 index 0d033a98a6..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/Util.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.servlet; - -import ch.qos.logback.access.AccessConstants; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -public class Util { - - public static boolean isFormUrlEncoded(HttpServletRequest request) { - - String contentTypeStr = request.getContentType(); - if ("POST".equalsIgnoreCase(request.getMethod()) && contentTypeStr != null - && contentTypeStr.startsWith(AccessConstants.X_WWW_FORM_URLECODED)) { - return true; - } else { - return false; - } - } - - public static boolean isImageResponse(HttpServletResponse response) { - - String responseType = response.getContentType(); - - if (responseType != null && responseType.startsWith(AccessConstants.IMAGE_CONTENT_TYPE)) { - return true; - } else { - return false; - } - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/sift/AccessEventDiscriminator.java b/logback-access/src/main/java/ch/qos/logback/access/sift/AccessEventDiscriminator.java deleted file mode 100644 index 21ebd9603e..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/sift/AccessEventDiscriminator.java +++ /dev/null @@ -1,190 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.sift; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpSession; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.sift.AbstractDiscriminator; - -/** - * - * AccessEventDiscriminator's job is to return the value of a designated field - * in an {@link IAccessEvent} instance. - * - *

The field is specified via the {@link FieldName} property. - * - * @author Ceki Gülcü - * - */ -public class AccessEventDiscriminator extends AbstractDiscriminator { - - /** - * At present time the followed fields can be designated: COOKIE, - * REQUEST_ATTRIBUTE, SESSION_ATTRIBUTE, REMOTE_ADDRESS, - * LOCAL_PORT,REQUEST_URI - * - *

The first three fields require an additional key. For the - * SESSION_ATTRIBUTE field, the additional key named "id" has special meaning - * as it is mapped to the session id of the current http request. - */ - public enum FieldName { - COOKIE, REQUEST_ATTRIBUTE, SESSION_ATTRIBUTE, REMOTE_ADDRESS, LOCAL_PORT, REQUEST_URI - } - - String defaultValue; - String key; - FieldName fieldName; - String additionalKey; - - @Override - public String getDiscriminatingValue(IAccessEvent acccessEvent) { - String rawValue = getRawDiscriminatingValue(acccessEvent); - if (rawValue == null || rawValue.length() == 0) { - return defaultValue; - } else { - return rawValue; - } - } - - public String getRawDiscriminatingValue(IAccessEvent acccessEvent) { - switch (fieldName) { - case COOKIE: - // tested - return acccessEvent.getCookie(additionalKey); - case LOCAL_PORT: - return String.valueOf(acccessEvent.getLocalPort()); - case REQUEST_ATTRIBUTE: - // tested - return getRequestAttribute(acccessEvent); - case SESSION_ATTRIBUTE: - return getSessionAttribute(acccessEvent); - case REMOTE_ADDRESS: - return acccessEvent.getRemoteAddr(); - case REQUEST_URI: - // tested - return getRequestURI(acccessEvent); - default: - return null; - } - } - - private String getRequestAttribute(IAccessEvent acccessEvent) { - String attr = acccessEvent.getAttribute(additionalKey); - if (IAccessEvent.NA.equals(attr)) { - return null; - } else { - return attr; - } - } - - private String getRequestURI(IAccessEvent acccessEvent) { - String uri = acccessEvent.getRequestURI(); - if (uri != null && uri.length() >= 1 && uri.charAt(0) == '/') { - return uri.substring(1); - } else { - return uri; - } - } - - private String getSessionAttribute(IAccessEvent acccessEvent) { - HttpServletRequest req = acccessEvent.getRequest(); - if (req != null) { - HttpSession session = req.getSession(false); - if (session != null) { - if ("id".equalsIgnoreCase(additionalKey)) { - return session.getId(); - } else { - Object v = session.getAttribute(additionalKey); - if (v != null) { - return v.toString(); - } - } - } - } - return null; - } - - @Override - public void start() { - - int errorCount = 0; - - if (defaultValue == null) { - addError("\"DefaultValue\" property must be set."); - } - if (fieldName == null) { - addError("\"FieldName\" property must be set."); - errorCount++; - } - - switch (fieldName) { - case SESSION_ATTRIBUTE: - case REQUEST_ATTRIBUTE: - case COOKIE: - if (additionalKey == null) { - addError("\"OptionalKey\" property is mandatory for field name " + fieldName.toString()); - errorCount++; - } - } - - if (errorCount == 0) { - started = true; - } - } - - public void setFieldName(FieldName fieldName) { - this.fieldName = fieldName; - } - - public FieldName getFieldName() { - return fieldName; - } - - public String getAdditionalKey() { - return additionalKey; - } - - public void setAdditionalKey(String additionalKey) { - this.additionalKey = additionalKey; - } - - /** - * @see #setDefaultValue(String) - * @return - */ - public String getDefaultValue() { - return defaultValue; - } - - /** - * The default value returned by this discriminator in case it cannot compute - * the discriminating value from the access event. - * - * @param defaultValue - */ - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/sift/SiftingAppender.java b/logback-access/src/main/java/ch/qos/logback/access/sift/SiftingAppender.java deleted file mode 100644 index ddc43bacb8..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/sift/SiftingAppender.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.sift; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.joran.spi.DefaultClass; -import ch.qos.logback.core.sift.Discriminator; -import ch.qos.logback.core.sift.SiftingAppenderBase; - -/** - * This appender can contain other appenders which it can build dynamically - * depending on MDC values. The built appender is specified as part of a - * configuration file. - * - *

See the logback manual for further details. - * - * - * @author Ceki Gulcu - */ -public class SiftingAppender extends SiftingAppenderBase { - - @Override - public void start() { - super.start(); - } - - @Override - protected long getTimestamp(IAccessEvent event) { - return event.getTimeStamp(); - } - - @Override - protected boolean eventMarksEndOfLife(IAccessEvent event) { - return false; - } - - @Override - @DefaultClass(AccessEventDiscriminator.class) - public void setDiscriminator(Discriminator discriminator) { - super.setDiscriminator(discriminator); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessContext.java b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessContext.java deleted file mode 100644 index fd3d9c4a47..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessContext.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.spi; - -import java.util.Iterator; -import java.util.List; - -import ch.qos.logback.core.Appender; -import ch.qos.logback.core.ContextBase; -import ch.qos.logback.core.filter.Filter; -import ch.qos.logback.core.spi.AppenderAttachable; -import ch.qos.logback.core.spi.AppenderAttachableImpl; -import ch.qos.logback.core.spi.FilterAttachable; -import ch.qos.logback.core.spi.FilterAttachableImpl; -import ch.qos.logback.core.spi.FilterReply; - -/** - * A minimal context implementation used by certain logback-access components, - * mainly SocketServer. - * - * @author Sébastien Pennec - */ -public class AccessContext extends ContextBase - implements AppenderAttachable, FilterAttachable { - - AppenderAttachableImpl aai = new AppenderAttachableImpl(); - FilterAttachableImpl fai = new FilterAttachableImpl(); - - public void callAppenders(IAccessEvent event) { - aai.appendLoopOnAppenders(event); - } - - @Override - public void addAppender(Appender newAppender) { - aai.addAppender(newAppender); - } - - @Override - public void detachAndStopAllAppenders() { - aai.detachAndStopAllAppenders(); - } - - @Override - public boolean detachAppender(Appender appender) { - return aai.detachAppender(appender); - } - - @Override - public boolean detachAppender(String name) { - return aai.detachAppender(name); - } - - @Override - public Appender getAppender(String name) { - return aai.getAppender(name); - } - - @Override - public boolean isAttached(Appender appender) { - return aai.isAttached(appender); - } - - @Override - public Iterator> iteratorForAppenders() { - return aai.iteratorForAppenders(); - } - - @Override - public void addFilter(Filter newFilter) { - fai.addFilter(newFilter); - } - - @Override - public void clearAllFilters() { - fai.clearAllFilters(); - } - - @Override - public List> getCopyOfAttachedFiltersList() { - return fai.getCopyOfAttachedFiltersList(); - } - - @Override - public FilterReply getFilterChainDecision(IAccessEvent event) { - return fai.getFilterChainDecision(event); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java deleted file mode 100755 index fe32b68460..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java +++ /dev/null @@ -1,636 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.spi; - -import ch.qos.logback.access.AccessConstants; -import ch.qos.logback.access.pattern.AccessConverter; -import ch.qos.logback.access.servlet.Util; -import ch.qos.logback.core.Context; -import ch.qos.logback.core.spi.SequenceNumberGenerator; - -import jakarta.servlet.http.Cookie; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.servlet.http.HttpSession; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.Vector; - -// Contributors: Joern Huxhorn (see also bug #110) - -/** - * The Access module's internal representation of logging events. When the - * logging component instance is called in the container to log then a - * AccessEvent instance is created. This instance is passed around - * to the different logback components. - * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ -public class AccessEvent implements Serializable, IAccessEvent { - - private static final String[] NA_STRING_ARRAY = new String[] { NA }; - - private static final long serialVersionUID = 866718993618836343L; - - private static final String EMPTY = ""; - - private transient final HttpServletRequest httpRequest; - private transient final HttpServletResponse httpResponse; - - String queryString; - String requestURI; - String requestURL; - String remoteHost; - String remoteUser; - String remoteAddr; - String threadName; - String protocol; - String method; - String serverName; - String requestContent; - String responseContent; - String sessionID; - long elapsedTime; - - Map requestHeaderMap; - Map requestParameterMap; - Map responseHeaderMap; - Map attributeMap; - - long contentLength = SENTINEL; - int statusCode = SENTINEL; - int localPort = SENTINEL; - - transient ServerAdapter serverAdapter; - - /** - * The number of milliseconds elapsed from 1/1/1970 until logging event was - * created. - */ - private long timeStamp = 0; - - private long sequenceNumber = 0; - - public AccessEvent(Context context, HttpServletRequest httpRequest, HttpServletResponse httpResponse, - ServerAdapter adapter) { - this.httpRequest = httpRequest; - this.httpResponse = httpResponse; - this.timeStamp = System.currentTimeMillis(); - - SequenceNumberGenerator sng = context.getSequenceNumberGenerator(); - if (sng != null) { - this.sequenceNumber = sng.nextSequenceNumber(); - } - this.serverAdapter = adapter; - this.elapsedTime = calculateElapsedTime(); - } - - /** - * Returns the underlying HttpServletRequest. After serialization the returned - * value will be null. - * - * @return - */ - @Override - public HttpServletRequest getRequest() { - return httpRequest; - } - - /** - * Returns the underlying HttpServletResponse. After serialization the returned - * value will be null. - * - * @return - */ - @Override - public HttpServletResponse getResponse() { - return httpResponse; - } - - @Override - public long getTimeStamp() { - return timeStamp; - } - - public void setTimeStamp(long timeStamp) { - this.timeStamp = timeStamp; - } - - public long getSequenceNumber() { - return sequenceNumber; - } - - public void setSequenceNumber(long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - } - - /** - * @param threadName The threadName to set. - */ - public void setThreadName(String threadName) { - this.threadName = threadName; - } - - @Override - public String getThreadName() { - return threadName == null ? NA : threadName; - } - - @Override - public String getRequestURI() { - if (requestURI == null) { - if (httpRequest != null) { - requestURI = httpRequest.getRequestURI(); - } else { - requestURI = NA; - } - } - return requestURI; - } - - @Override - public String getQueryString() { - if (queryString == null) { - if (httpRequest != null) { - StringBuilder buf = new StringBuilder(); - final String qStr = httpRequest.getQueryString(); - if (qStr != null) { - buf.append(AccessConverter.QUESTION_CHAR); - buf.append(qStr); - } - queryString = buf.toString(); - } else { - queryString = NA; - } - } - return queryString; - } - - /** - * The first line of the request. - */ - @Override - public String getRequestURL() { - if (requestURL == null) { - if (httpRequest != null) { - StringBuilder buf = new StringBuilder(); - buf.append(httpRequest.getMethod()); - buf.append(AccessConverter.SPACE_CHAR); - buf.append(httpRequest.getRequestURI()); - buf.append(getQueryString()); - buf.append(AccessConverter.SPACE_CHAR); - buf.append(httpRequest.getProtocol()); - requestURL = buf.toString(); - } else { - requestURL = NA; - } - } - return requestURL; - } - - @Override - public String getRemoteHost() { - if (remoteHost == null) { - if (httpRequest != null) { - // the underlying implementation of HttpServletRequest will - // determine if remote lookup will be performed - remoteHost = httpRequest.getRemoteHost(); - } else { - remoteHost = NA; - } - } - return remoteHost; - } - - @Override - public String getRemoteUser() { - if (remoteUser == null) { - if (httpRequest != null) { - remoteUser = httpRequest.getRemoteUser(); - } else { - remoteUser = NA; - } - } - return remoteUser; - } - - @Override - public String getProtocol() { - if (protocol == null) { - if (httpRequest != null) { - protocol = httpRequest.getProtocol(); - } else { - protocol = NA; - } - } - return protocol; - } - - @Override - public String getMethod() { - if (method == null) { - if (httpRequest != null) { - method = httpRequest.getMethod(); - } else { - method = NA; - } - } - return method; - } - - @Override - public String getSessionID() { - if (sessionID == null) { - if (httpRequest != null) { - final HttpSession session = httpRequest.getSession(false); - if (session != null) { - sessionID = session.getId(); - } - } else { - sessionID = NA; - } - } - return sessionID; - } - - @Override - public String getServerName() { - if (serverName == null) { - if (httpRequest != null) { - serverName = httpRequest.getServerName(); - } else { - serverName = NA; - } - } - return serverName; - } - - @Override - public String getRemoteAddr() { - if (remoteAddr == null) { - if (httpRequest != null) { - remoteAddr = httpRequest.getRemoteAddr(); - } else { - remoteAddr = NA; - } - } - return remoteAddr; - } - - @Override - public String getRequestHeader(String key) { - String result = null; - key = key.toLowerCase(); - if (requestHeaderMap == null) { - if (httpRequest != null) { - buildRequestHeaderMap(); - result = requestHeaderMap.get(key); - } - } else { - result = requestHeaderMap.get(key); - } - - if (result != null) { - return result; - } else { - return NA; - } - } - - @Override - public Enumeration getRequestHeaderNames() { - // post-serialization - if (httpRequest == null) { - Vector list = new Vector(getRequestHeaderMap().keySet()); - return list.elements(); - } - return httpRequest.getHeaderNames(); - } - - @Override - public Map getRequestHeaderMap() { - if (requestHeaderMap == null) { - buildRequestHeaderMap(); - } - return requestHeaderMap; - } - - public void buildRequestHeaderMap() { - // according to RFC 2616 header names are case-insensitive - // latest versions of Tomcat return header names in lower-case - requestHeaderMap = new TreeMap(String.CASE_INSENSITIVE_ORDER); - Enumeration e = httpRequest.getHeaderNames(); - if (e == null) { - return; - } - while (e.hasMoreElements()) { - String key = e.nextElement(); - requestHeaderMap.put(key, httpRequest.getHeader(key)); - } - } - - public void buildRequestParameterMap() { - requestParameterMap = new HashMap(); - try { - Enumeration e = httpRequest.getParameterNames(); - if (e == null) { - return; - } - while (e.hasMoreElements()) { - String key = e.nextElement(); - requestParameterMap.put(key, httpRequest.getParameterValues(key)); - } - } catch(Throwable t) { - // The use of HttpServletRequest.getParameterNames() can cause - // a READ of the Request body content. This can fail with various - // Throwable failures depending on the state of the Request - // at the time this method is called. - // We don't want to fail the logging due to these types of requests - t.printStackTrace(); - } - } - - @Override - public Map getRequestParameterMap() { - if (requestParameterMap == null) { - buildRequestParameterMap(); - } - return requestParameterMap; - } - - @Override - public String getAttribute(String key) { - Object value = null; - if (attributeMap != null) { - // Event was prepared for deferred processing so we have a copy of attribute map - // and must use that copy - value = attributeMap.get(key); - } else if (httpRequest != null) { - // We have original request so take attribute from it - value = httpRequest.getAttribute(key); - } - - return value != null ? value.toString() : NA; - } - - private void copyAttributeMap() { - - if (httpRequest == null) { - return; - } - - // attributeMap has been copied already. See also LOGBACK-1189 - if (attributeMap != null) { - return; - } - - attributeMap = new HashMap(); - - Enumeration names = httpRequest.getAttributeNames(); - while (names.hasMoreElements()) { - String name = names.nextElement(); - - Object value = httpRequest.getAttribute(name); - if (shouldCopyAttribute(name, value)) { - attributeMap.put(name, value); - } - } - } - - private boolean shouldCopyAttribute(String name, Object value) { - if (AccessConstants.LB_INPUT_BUFFER.equals(name) || AccessConstants.LB_OUTPUT_BUFFER.equals(name)) { - // Do not copy attributes used by logback internally - these are available via - // other getters anyway - return false; - } else if (value == null) { - // No reasons to copy nulls - Map.get() will return null for missing keys and - // the list of attribute - // names is not available through IAccessEvent - return false; - } else { - // Only copy what is serializable - return value instanceof Serializable; - } - } - - @Override - public String[] getRequestParameter(String key) { - String[] value = null; - - if (requestParameterMap != null) { - value = requestParameterMap.get(key); - } else if (httpRequest != null) { - value = httpRequest.getParameterValues(key); - } - - return (value != null) ? value : NA_STRING_ARRAY; - } - - @Override - public String getCookie(String key) { - - if (httpRequest != null) { - Cookie[] cookieArray = httpRequest.getCookies(); - if (cookieArray == null) { - return NA; - } - - for (Cookie cookie : cookieArray) { - if (key.equals(cookie.getName())) { - return cookie.getValue(); - } - } - } - return NA; - } - - @Override - public long getContentLength() { - if (contentLength == SENTINEL) { - if (httpResponse != null) { - contentLength = serverAdapter.getContentLength(); - return contentLength; - } - } - return contentLength; - } - - public int getStatusCode() { - if (statusCode == SENTINEL) { - if (httpResponse != null) { - statusCode = serverAdapter.getStatusCode(); - } - } - return statusCode; - } - - public long getElapsedSeconds() { - return elapsedTime < 0 ? elapsedTime : elapsedTime / 1000; - } - - public long getElapsedTime() { - return elapsedTime; - } - - private long calculateElapsedTime() { - if (serverAdapter.getRequestTimestamp() < 0) { - return -1; - } - return getTimeStamp() - serverAdapter.getRequestTimestamp(); - } - - public String getRequestContent() { - if (requestContent != null) { - return requestContent; - } - - if (Util.isFormUrlEncoded(httpRequest)) { - StringBuilder buf = new StringBuilder(); - - try { - Enumeration pramEnumeration = httpRequest.getParameterNames(); - - // example: id=1234&user=cgu - // number=1233&x=1 - int count = 0; - while (pramEnumeration.hasMoreElements()) { - - String key = pramEnumeration.nextElement(); - if (count++ != 0) { - buf.append("&"); - } - buf.append(key); - buf.append("="); - String val = httpRequest.getParameter(key); - if (val != null) { - buf.append(val); - } else { - buf.append(""); - } - } - } catch (Throwable t) { - // The use of HttpServletRequest.getParameterNames() and - // HttpServletRequest.getParameter(String) can cause - // a READ of the Request body content. This can fail with various - // Throwable failures depending on the state of the Request - // at the time this method is called. - // We don't want to fail the logging due to these types of requests - t.printStackTrace(); - } - requestContent = buf.toString(); - } else { - // retrieve the byte array placed by TeeFilter - byte[] inputBuffer = (byte[]) httpRequest.getAttribute(AccessConstants.LB_INPUT_BUFFER); - - if (inputBuffer != null) { - requestContent = new String(inputBuffer); - } - - if (requestContent == null || requestContent.length() == 0) { - requestContent = EMPTY; - } - } - - return requestContent; - } - - public String getResponseContent() { - if (responseContent != null) { - return responseContent; - } - - if (Util.isImageResponse(httpResponse)) { - responseContent = "[IMAGE CONTENTS SUPPRESSED]"; - } else { - - // retrieve the byte array previously placed by TeeFilter - byte[] outputBuffer = (byte[]) httpRequest.getAttribute(AccessConstants.LB_OUTPUT_BUFFER); - - if (outputBuffer != null) { - responseContent = new String(outputBuffer); - } - if (responseContent == null || responseContent.length() == 0) { - responseContent = EMPTY; - } - } - - return responseContent; - } - - public int getLocalPort() { - if (localPort == SENTINEL) { - if (httpRequest != null) { - localPort = httpRequest.getLocalPort(); - } - - } - return localPort; - } - - public ServerAdapter getServerAdapter() { - return serverAdapter; - } - - public String getResponseHeader(String key) { - buildResponseHeaderMap(); - return responseHeaderMap.get(key); - } - - void buildResponseHeaderMap() { - if (responseHeaderMap == null) { - responseHeaderMap = serverAdapter.buildResponseHeaderMap(); - } - } - - public Map getResponseHeaderMap() { - buildResponseHeaderMap(); - return responseHeaderMap; - } - - public List getResponseHeaderNameList() { - buildResponseHeaderMap(); - return new ArrayList(responseHeaderMap.keySet()); - } - - public void prepareForDeferredProcessing() { - getRequestHeaderMap(); - getRequestParameterMap(); - getResponseHeaderMap(); - getLocalPort(); - getMethod(); - getProtocol(); - getRemoteAddr(); - getRemoteHost(); - getRemoteUser(); - getRequestURI(); - getRequestURL(); - getServerName(); - getTimeStamp(); - getElapsedTime(); - - getStatusCode(); - getContentLength(); - getRequestContent(); - getResponseContent(); - - copyAttributeMap(); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/IAccessEvent.java b/logback-access/src/main/java/ch/qos/logback/access/spi/IAccessEvent.java deleted file mode 100644 index 89c93aa2ca..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/spi/IAccessEvent.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.spi; - -import ch.qos.logback.core.spi.DeferredProcessingAware; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.util.Enumeration; -import java.util.List; -import java.util.Map; - -// Contributors: Joern Huxhorn (see also bug #110) - -/** - * The Access module's internal representation of logging events. When the - * logging component instance is called in the container to log then a - * AccessEvent instance is created. This instance is passed around - * to the different logback components. - * - * @author Ceki Gülcü - * @author Sébastien Pennec - * @author Jörn Huxhorn - */ -public interface IAccessEvent extends DeferredProcessingAware { - - String NA = "-"; - int SENTINEL = -1; - - /** - * Returns the underlying HttpServletRequest. After serialization the returned - * value will be null. - * - * @return - */ - HttpServletRequest getRequest(); - - /** - * Returns the underlying HttpServletResponse. After serialization the returned - * value will be null. - * - * @return - */ - HttpServletResponse getResponse(); - - /** - * The number of milliseconds elapsed from 1/1/1970 until logging event was - * created. - */ - long getTimeStamp(); - - /** - * The sequence number associated with this event. - * - *

- * Sequence numbers, if present, should be increasing monotonically. - * - * @since 1.3.0 - */ - - long getSequenceNumber(); - - /** - * The time elapsed between receiving the request and logging it in - * milliseconds. - */ - long getElapsedTime(); - - /** - * The number of seconds elapsed between receiving the request and logging it. - */ - long getElapsedSeconds(); - - String getRequestURI(); - - /** - * The first line of the request. - */ - String getRequestURL(); - - String getRemoteHost(); - - String getRemoteUser(); - - String getProtocol(); - - String getMethod(); - - String getServerName(); - - String getSessionID(); - - void setThreadName(String threadName); - - String getThreadName(); - - String getQueryString(); - - String getRemoteAddr(); - - String getRequestHeader(String key); - - Enumeration getRequestHeaderNames(); - - Map getRequestHeaderMap(); - - Map getRequestParameterMap(); - - String getAttribute(String key); - - String[] getRequestParameter(String key); - - String getCookie(String key); - - long getContentLength(); - - int getStatusCode(); - - String getRequestContent(); - - String getResponseContent(); - - int getLocalPort(); - - ServerAdapter getServerAdapter(); - - String getResponseHeader(String key); - - Map getResponseHeaderMap(); - - List getResponseHeaderNameList(); -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/ServerAdapter.java b/logback-access/src/main/java/ch/qos/logback/access/spi/ServerAdapter.java deleted file mode 100644 index 4031b61e08..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/spi/ServerAdapter.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.spi; - -import java.util.Map; - -/** - * An interface to access server-specific methods from the server-independent - * AccessEvent. - * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ -public interface ServerAdapter { - - long getRequestTimestamp(); - - long getContentLength(); - - int getStatusCode(); - - Map buildResponseHeaderMap(); -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/Util.java b/logback-access/src/main/java/ch/qos/logback/access/spi/Util.java deleted file mode 100644 index 815ec60514..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/spi/Util.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.spi; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - -public class Util { - static final int BUF_SIZE = 128; - - public static String readToString(InputStream in) throws IOException { - if (in == null) { - return null; - } - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] buf = new byte[BUF_SIZE]; - int n = 0; - while ((n = in.read(buf, 0, BUF_SIZE)) != -1) { - baos.write(buf, 0, n); - } - return baos.toString(); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/package.html b/logback-access/src/main/java/ch/qos/logback/access/spi/package.html deleted file mode 100644 index 08b45592c1..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/spi/package.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - -

Contains the core classes of logback access.

- - - \ No newline at end of file diff --git a/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java b/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java deleted file mode 100644 index bc5b00aafd..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java +++ /dev/null @@ -1,488 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.tomcat; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; - -import ch.qos.logback.core.spi.ConfigurationEvent; -import ch.qos.logback.core.spi.ConfigurationEventListener; -import jakarta.servlet.ServletContext; -import jakarta.servlet.ServletException; - -import org.apache.catalina.Lifecycle; -import org.apache.catalina.LifecycleException; -import org.apache.catalina.LifecycleListener; -import org.apache.catalina.LifecycleState; -import org.apache.catalina.connector.Request; -import org.apache.catalina.connector.Response; -import org.apache.catalina.valves.ValveBase; - -import ch.qos.logback.access.AccessConstants; -import ch.qos.logback.access.joran.JoranConfigurator; -import ch.qos.logback.access.spi.AccessEvent; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.Appender; -import ch.qos.logback.core.BasicStatusManager; -import ch.qos.logback.core.Context; -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.LifeCycleManager; -import ch.qos.logback.core.boolex.EventEvaluator; -import ch.qos.logback.core.filter.Filter; -import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.spi.AppenderAttachable; -import ch.qos.logback.core.spi.AppenderAttachableImpl; -import ch.qos.logback.core.spi.FilterAttachable; -import ch.qos.logback.core.spi.FilterAttachableImpl; -import ch.qos.logback.core.spi.FilterReply; -import ch.qos.logback.core.spi.LifeCycle; -import ch.qos.logback.core.spi.LogbackLock; -import ch.qos.logback.core.spi.SequenceNumberGenerator; -import ch.qos.logback.core.status.ErrorStatus; -import ch.qos.logback.core.status.InfoStatus; -import ch.qos.logback.core.status.OnConsoleStatusListener; -import ch.qos.logback.core.status.Status; -import ch.qos.logback.core.status.StatusManager; -import ch.qos.logback.core.status.WarnStatus; -import ch.qos.logback.core.util.ExecutorServiceUtil; -import ch.qos.logback.core.util.Loader; -import ch.qos.logback.core.util.OptionHelper; -import ch.qos.logback.core.util.StatusListenerConfigHelper; - -//import org.apache.catalina.Lifecycle; - -/** - * This class is an implementation of tomcat's Valve interface, by extending - * ValveBase. - * - *

- * For more information on using LogbackValve please refer to the online - * documentation on - * logback-access and - * tomcat. - * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ -public class LogbackValve extends ValveBase - implements Lifecycle, Context, AppenderAttachable, FilterAttachable { - - public final static String DEFAULT_FILENAME = "logback-access.xml"; - public final static String DEFAULT_CONFIG_FILE = "conf" + File.separatorChar + DEFAULT_FILENAME; - final static String CATALINA_BASE_KEY = "catalina.base"; - final static String CATALINA_HOME_KEY = "catalina.home"; - - private final LifeCycleManager lifeCycleManager = new LifeCycleManager(); - - private long birthTime = System.currentTimeMillis(); - - LogbackLock configurationLock = new LogbackLock(); - - final private List configurationEventListenerList = new ArrayList<>(); - - // Attributes from ContextBase: - private String name; - StatusManager sm = new BasicStatusManager(); - // TODO propertyMap should be observable so that we can be notified - // when it changes so that a new instance of propertyMap can be - // serialized. For the time being, we ignore this shortcoming. - Map propertyMap = new HashMap(); - Map objectMap = new HashMap(); - private FilterAttachableImpl fai = new FilterAttachableImpl(); - - AppenderAttachableImpl aai = new AppenderAttachableImpl(); - String filenameOption; - boolean quiet; - boolean started; - boolean alreadySetLogbackStatusManager = false; - private SequenceNumberGenerator sequenceNumberGenerator; - - private ScheduledExecutorService scheduledExecutorService; - - public LogbackValve() { - putObject(CoreConstants.EVALUATOR_MAP, new HashMap>()); - } - - public boolean isStarted() { - return started; - } - - @Override - public void startInternal() throws LifecycleException { - scheduledExecutorService = ExecutorServiceUtil.newScheduledExecutorService(); - - String filename; - - if (filenameOption != null) { - filename = filenameOption; - } else { - addInfo("filename property not set. Assuming [" + DEFAULT_CONFIG_FILE + "]"); - filename = DEFAULT_CONFIG_FILE; - } - - // String catalinaBase = OptionHelper.getSystemProperty(CATALINA_BASE_KEY); - // String catalinaHome = OptionHelper.getSystemProperty(CATALINA_BASE_KEY); - - File configFile = searchForConfigFileTomcatProperty(filename, CATALINA_BASE_KEY); - if (configFile == null) { - configFile = searchForConfigFileTomcatProperty(filename, CATALINA_HOME_KEY); - } - - URL resourceURL; - if (configFile != null) - resourceURL = fileToUrl(configFile); - else - resourceURL = searchAsResource(filename); - - if (resourceURL != null) { - configureAsResource(resourceURL); - } else { - addWarn("Failed to find valid logback-access configuration file."); - } - - if (!quiet) { - StatusListenerConfigHelper.addOnConsoleListenerInstance(this, new OnConsoleStatusListener()); - } - - started = true; - setState(LifecycleState.STARTING); - } - - private URL fileToUrl(File configFile) { - try { - return configFile.toURI().toURL(); - } catch (MalformedURLException e) { - throw new IllegalStateException("File to URL conversion failed", e); - } - } - - private URL searchAsResource(String filename) { - URL result = Loader.getResource(filename, getClass().getClassLoader()); - if (result != null) - addInfo("Found [" + filename + "] as a resource."); - else - addInfo("Could NOT find [" + filename + "] as a resource."); - return result; - } - - private File searchForConfigFileTomcatProperty(String filename, String propertyKey) { - String propertyValue = OptionHelper.getSystemProperty(propertyKey); - String candidatePath = propertyValue + File.separatorChar + filename; - if (propertyValue == null) { - addInfo("System property \"" + propertyKey + "\" is not set. Skipping configuration file search with ${" - + propertyKey + "} path prefix."); - return null; - } - File candidateFile = new File(candidatePath); - if (candidateFile.exists()) { - addInfo("Found configuration file [" + candidatePath + "] using property \"" + propertyKey + "\""); - return candidateFile; - } else { - addInfo("Could NOT find configuration file [" + candidatePath + "] using property \"" + propertyKey + "\""); - return null; - } - } - - public void addStatus(Status status) { - StatusManager sm = getStatusManager(); - if (sm != null) { - sm.add(status); - } - } - - public void addInfo(String msg) { - addStatus(new InfoStatus(msg, this)); - } - - public void addWarn(String msg) { - addStatus(new WarnStatus(msg, this)); - } - - public void addError(String msg, Throwable t) { - addStatus(new ErrorStatus(msg, this, t)); - } - - private void configureAsResource(URL resourceURL) { - try { - JoranConfigurator jc = new JoranConfigurator(); - jc.setContext(this); - jc.doConfigure(resourceURL); - addInfo("Done configuring"); - } catch (JoranException e) { - addError("Failed to configure LogbackValve", e); - } - } - - public String getFilename() { - return filenameOption; - } - - public void setFilename(String filename) { - this.filenameOption = filename; - } - - public boolean isQuiet() { - return quiet; - } - - public void setQuiet(boolean quiet) { - this.quiet = quiet; - } - - @Override - public void invoke(Request request, Response response) throws IOException, ServletException { - try { - if (!alreadySetLogbackStatusManager) { - alreadySetLogbackStatusManager = true; - org.apache.catalina.Context tomcatContext = request.getContext(); - if (tomcatContext != null) { - ServletContext sc = tomcatContext.getServletContext(); - if (sc != null) { - sc.setAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY, getStatusManager()); - } - } - } - - getNext().invoke(request, response); - - TomcatServerAdapter adapter = new TomcatServerAdapter(request, response); - IAccessEvent accessEvent = new AccessEvent(this, request, response, adapter); - - addThreadName(accessEvent); - - if (getFilterChainDecision(accessEvent) == FilterReply.DENY) { - return; - } - - // TODO better exception handling - aai.appendLoopOnAppenders(accessEvent); - } finally { - request.removeAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY); - } - } - - private void addThreadName(IAccessEvent accessEvent) { - try { - final String threadName = Thread.currentThread().getName(); - if (threadName != null) { - accessEvent.setThreadName(threadName); - } - } catch (Exception ignored) { - } - } - - @Override - protected void stopInternal() throws LifecycleException { - started = false; - setState(LifecycleState.STOPPING); - lifeCycleManager.reset(); - if (scheduledExecutorService != null) { - ExecutorServiceUtil.shutdown(scheduledExecutorService); - scheduledExecutorService = null; - } - } - - @Override - public void addAppender(Appender newAppender) { - aai.addAppender(newAppender); - } - - @Override - public Iterator> iteratorForAppenders() { - return aai.iteratorForAppenders(); - } - - @Override - public Appender getAppender(String name) { - return aai.getAppender(name); - } - - @Override - public boolean isAttached(Appender appender) { - return aai.isAttached(appender); - } - - @Override - public void detachAndStopAllAppenders() { - aai.detachAndStopAllAppenders(); - - } - - @Override - public boolean detachAppender(Appender appender) { - return aai.detachAppender(appender); - } - - @Override - public boolean detachAppender(String name) { - return aai.detachAppender(name); - } - - public String getInfo() { - return "Logback's implementation of ValveBase"; - } - - // Methods from ContextBase: - @Override - public StatusManager getStatusManager() { - return sm; - } - - public Map getPropertyMap() { - return propertyMap; - } - - @Override - public void putProperty(String key, String val) { - this.propertyMap.put(key, val); - } - - @Override - public String getProperty(String key) { - return (String) this.propertyMap.get(key); - } - - @Override - public Map getCopyOfPropertyMap() { - return new HashMap(this.propertyMap); - } - - @Override - public Object getObject(String key) { - return objectMap.get(key); - } - - @Override - public void putObject(String key, Object value) { - objectMap.put(key, value); - } - - @Override - public void addFilter(Filter newFilter) { - fai.addFilter(newFilter); - } - - @Override - public void clearAllFilters() { - fai.clearAllFilters(); - } - - @Override - public List> getCopyOfAttachedFiltersList() { - return fai.getCopyOfAttachedFiltersList(); - } - - @Override - public FilterReply getFilterChainDecision(IAccessEvent event) { - return fai.getFilterChainDecision(event); - } - - @Override - public ExecutorService getExecutorService() { - return getScheduledExecutorService(); - } - - @Override - public String getName() { - return name; - } - - @Override - public void setName(String name) { - if (this.name != null) { - throw new IllegalStateException("LogbackValve has been already given a name"); - } - this.name = name; - } - - @Override - public long getBirthTime() { - return birthTime; - } - - @Override - public Object getConfigurationLock() { - return configurationLock; - } - - @Override - public void register(LifeCycle component) { - lifeCycleManager.register(component); - } - - // ====== Methods from catalina Lifecycle ===== - - @Override - public void addLifecycleListener(LifecycleListener arg0) { - // dummy NOP implementation - } - - @Override - public LifecycleListener[] findLifecycleListeners() { - return new LifecycleListener[0]; - } - - @Override - public void removeLifecycleListener(LifecycleListener arg0) { - // dummy NOP implementation - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(this.getClass().getName()); - sb.append('['); - sb.append(getName()); - sb.append(']'); - return sb.toString(); - } - - @Override - public ScheduledExecutorService getScheduledExecutorService() { - return scheduledExecutorService; - } - - @Override - public void addScheduledFuture(ScheduledFuture scheduledFuture) { - throw new UnsupportedOperationException(); - } - - public SequenceNumberGenerator getSequenceNumberGenerator() { - return sequenceNumberGenerator; - } - - public void setSequenceNumberGenerator(SequenceNumberGenerator sequenceNumberGenerator) { - this.sequenceNumberGenerator = sequenceNumberGenerator; - } - - - @Override - public void addConfigurationEventListener(ConfigurationEventListener listener) { - configurationEventListenerList.add(listener); - } - - @Override - public void fireConfigurationEvent(ConfigurationEvent configurationEvent) { - configurationEventListenerList.forEach( l -> l.listen(configurationEvent)); - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/tomcat/TomcatServerAdapter.java b/logback-access/src/main/java/ch/qos/logback/access/tomcat/TomcatServerAdapter.java deleted file mode 100644 index a08f572c94..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/tomcat/TomcatServerAdapter.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.tomcat; - -import ch.qos.logback.access.spi.ServerAdapter; - -import org.apache.catalina.connector.Request; -import org.apache.catalina.connector.Response; - -import java.util.HashMap; -import java.util.Map; - -/** - * A tomcat specific implementation of the {@link ServerAdapter} interface. - * - * @author Sébastien Pennec - */ -public class TomcatServerAdapter implements ServerAdapter { - - Request request; - Response response; - - public TomcatServerAdapter(Request tomcatRequest, Response tomcatResponse) { - this.request = tomcatRequest; - this.response = tomcatResponse; - } - - @Override - public long getContentLength() { - return response.getContentLength(); - } - - @Override - public int getStatusCode() { - return response.getStatus(); - } - - @Override - public long getRequestTimestamp() { - return request.getCoyoteRequest().getStartTime(); - } - - @Override - public Map buildResponseHeaderMap() { - Map responseHeaderMap = new HashMap(); - for (String key : response.getHeaderNames()) { - String value = response.getHeader(key); - responseHeaderMap.put(key, value); - } - return responseHeaderMap; - } -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/tomcat/package.html b/logback-access/src/main/java/ch/qos/logback/access/tomcat/package.html deleted file mode 100644 index c96b85259f..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/tomcat/package.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - -

This is logback access' implementation for Tomcat.

- - - \ No newline at end of file diff --git a/logback-access/src/main/java/module-info.DISABLED b/logback-access/src/main/java/module-info.DISABLED deleted file mode 100644 index 789bd246d8..0000000000 --- a/logback-access/src/main/java/module-info.DISABLED +++ /dev/null @@ -1,13 +0,0 @@ -module ch.qos.logback.access { - requires ch.qos.logback.core; - - // jakarta.servlet 5.0 is not modular - requires static jakarta.servlet; - requires static java.management; - - requires static org.apache.tomcat.coyote; - requires static org.apache.tomcat.catalina; - - -} - diff --git a/logback-access/src/main/resources/ch/qos/logback/access/db/script/db2.sql b/logback-access/src/main/resources/ch/qos/logback/access/db/script/db2.sql deleted file mode 100644 index 4fedc9dd70..0000000000 --- a/logback-access/src/main/resources/ch/qos/logback/access/db/script/db2.sql +++ /dev/null @@ -1,42 +0,0 @@ -# Logback: the reliable, generic, fast and flexible logging framework. -# Copyright (C) 1999-2010, QOS.ch. All rights reserved. -# -# See http://logback.qos.ch/license.html for the applicable licensing -# conditions. - -# This SQL script creates the required tables by ch.qos.logback.access.db.DBAppender -# -# It is intended for IBM DB2 databases. -# -# WARNING WARNING WARNING WARNING -# ================================= -# This SQL script has not been tested on an actual DB2 -# instance. It may contain errors or even invalid SQL -# statements. - -DROP TABLE access_event_header; -DROP TABLE access_event; - -CREATE TABLE access_event - ( - timestmp BIGINT NOT NULL, - requestURI VARCHAR(254), - requestURL VARCHAR(254), - remoteHost VARCHAR(254), - remoteUser VARCHAR(254), - remoteAddr VARCHAR(254), - protocol VARCHAR(254), - method VARCHAR(254), - serverName VARCHAR(254), - postContent VARCHAR(254), - event_id INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1) - ); - -CREATE TABLE access_event_header - ( - event_id INTEGER NOT NULL, - header_key VARCHAR(254) NOT NULL, - header_value VARCHAR(1024), - PRIMARY KEY(event_id, header_key), - FOREIGN KEY (event_id) REFERENCES access_event(event_id) - ); diff --git a/logback-access/src/main/resources/ch/qos/logback/access/db/script/db2l.sql b/logback-access/src/main/resources/ch/qos/logback/access/db/script/db2l.sql deleted file mode 100644 index dbf008c288..0000000000 --- a/logback-access/src/main/resources/ch/qos/logback/access/db/script/db2l.sql +++ /dev/null @@ -1,32 +0,0 @@ -# This SQL script creates the required tables by ch.qos.logback.access.db.DBAppender -# -# It is intended for PostgreSQL databases. - -DROP TABLE access_event_header; -DROP TABLE access_event; - -CREATE SEQUENCE access_event_id_seq MINVALUE 1 START 1; - -CREATE TABLE access_event - ( - timestmp BIGINT NOT NULL, - requestURI VARCHAR(254), - requestURL VARCHAR(254), - remoteHost VARCHAR(254), - remoteUser VARCHAR(254), - remoteAddr VARCHAR(254), - protocol VARCHAR(254), - method VARCHAR(254), - serverName VARCHAR(254), - postContent VARCHAR(254), - event_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY - ); - -CREATE TABLE access_event_header - ( - event_id INT NOT NULL, - header_key VARCHAR(254) NOT NULL, - header_value VARCHAR(1024), - PRIMARY KEY(event_id, header_key), - FOREIGN KEY (event_id) REFERENCES access_event(event_id) - ); \ No newline at end of file diff --git a/logback-access/src/main/resources/ch/qos/logback/access/db/script/hsqldb.sql b/logback-access/src/main/resources/ch/qos/logback/access/db/script/hsqldb.sql deleted file mode 100644 index 459a16b6fb..0000000000 --- a/logback-access/src/main/resources/ch/qos/logback/access/db/script/hsqldb.sql +++ /dev/null @@ -1,34 +0,0 @@ -# Logback: the reliable, generic, fast and flexible logging framework. -# Copyright (C) 1999-2010, QOS.ch. All rights reserved. -# -# See http://logback.qos.ch/license.html for the applicable licensing -# conditions. - -# This SQL script creates the required tables by ch.qos.logback.access.db.DBAppender -# -# It is intended for HSQL databases. - - -DROP TABLE access_event_header IF EXISTS; -DROP TABLE access_event IF EXISTS; - -CREATE TABLE access_event ( - timestmp BIGINT NOT NULL, - requestURI VARCHAR(254), - requestURL VARCHAR(254), - remoteHost VARCHAR(254), - remoteUser VARCHAR(254), - remoteAddr VARCHAR(254), - protocol VARCHAR(254), - method VARCHAR(254), - serverName VARCHAR(254), - postContent VARCHAR(254), - event_id BIGINT NOT NULL IDENTITY); - - -CREATE TABLE access_event_header ( - event_id BIGINT NOT NULL, - header_key VARCHAR(254) NOT NULL, - header_value LONGVARCHAR, - PRIMARY KEY(event_id, header_key), - FOREIGN KEY (event_id) REFERENCES access_event(event_id)); \ No newline at end of file diff --git a/logback-access/src/main/resources/ch/qos/logback/access/db/script/msSQLServer.sql b/logback-access/src/main/resources/ch/qos/logback/access/db/script/msSQLServer.sql deleted file mode 100644 index 7524ad3193..0000000000 --- a/logback-access/src/main/resources/ch/qos/logback/access/db/script/msSQLServer.sql +++ /dev/null @@ -1,37 +0,0 @@ --- Logback: the reliable, generic, fast and flexible logging framework. --- Copyright (C) 1999-2010, QOS.ch. All rights reserved. --- --- See http://logback.qos.ch/license.html for the applicable licensing --- conditions. - --- This SQL script creates the required tables by ch.qos.logback.access.db.DBAppender --- - -DROP TABLE access_event_header -DROP TABLE access_event - -CREATE TABLE access_event - ( - timestmp BIGINT NOT NULL, - requestURI VARCHAR(254), - requestURL VARCHAR(254), - remoteHost VARCHAR(254), - remoteUser VARCHAR(254), - remoteAddr VARCHAR(254), - protocol VARCHAR(254), - method VARCHAR(254), - serverName VARCHAR(254), - postContent VARCHAR(254), - event_id INT NOT NULL identity, - PRIMARY KEY(event_id) - ) - -CREATE TABLE access_event_header - ( - event_id INT NOT NULL, - header_key VARCHAR(254) NOT NULL, - header_value VARCHAR(1024), - PRIMARY KEY(event_id, header_key), - FOREIGN KEY (event_id) REFERENCES access_event(event_id) - ) - diff --git a/logback-access/src/main/resources/ch/qos/logback/access/db/script/mysql.sql b/logback-access/src/main/resources/ch/qos/logback/access/db/script/mysql.sql deleted file mode 100644 index 16e0e458e0..0000000000 --- a/logback-access/src/main/resources/ch/qos/logback/access/db/script/mysql.sql +++ /dev/null @@ -1,44 +0,0 @@ -# Logback: the reliable, generic, fast and flexible logging framework. -# Copyright (C) 1999-2010, QOS.ch. All rights reserved. -# -# See http://logback.qos.ch/license.html for the applicable licensing -# conditions. - -# This SQL script creates the required tables by ch.qos.logback.access.db.DBAppender. -# -# It is intended for MySQL databases. It has been tested on MySQL 5.5.31 with -# INNODB tables. - - -BEGIN; -DROP TABLE IF EXISTS access_event_header; -DROP TABLE IF EXISTS access_event; -COMMIT; - -BEGIN; -CREATE TABLE access_event - ( - timestmp BIGINT NOT NULL, - requestURI VARCHAR(254), - requestURL VARCHAR(254), - remoteHost VARCHAR(254), - remoteUser VARCHAR(254), - remoteAddr VARCHAR(254), - protocol VARCHAR(254), - method VARCHAR(254), - serverName VARCHAR(254), - postContent VARCHAR(254), - event_id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY - ); -COMMIT; - -BEGIN; -CREATE TABLE access_event_header - ( - event_id BIGINT NOT NULL, - header_key VARCHAR(254) NOT NULL, - header_value VARCHAR(1024), - PRIMARY KEY(event_id, header_key), - FOREIGN KEY (event_id) REFERENCES access_event(event_id) - ); -COMMIT; \ No newline at end of file diff --git a/logback-access/src/main/resources/ch/qos/logback/access/db/script/oracle.sql b/logback-access/src/main/resources/ch/qos/logback/access/db/script/oracle.sql deleted file mode 100644 index a47dc22fb5..0000000000 --- a/logback-access/src/main/resources/ch/qos/logback/access/db/script/oracle.sql +++ /dev/null @@ -1,56 +0,0 @@ --- Logback: the reliable, generic, fast and flexible logging framework. --- Copyright (C) 1999-2010, QOS.ch. All rights reserved. --- --- See http://logback.qos.ch/license.html for the applicable licensing --- conditions. - --- This SQL script creates the required tables by ch.qos.logback.access.db.DBAppender --- --- It is intended for Oracle databases. - - -CREATE SEQUENCE access_event_id_seq MINVALUE 1 START WITH 1; - - -CREATE TABLE access_event - ( - timestmp NUMBER(20) NOT NULL, - requestURI VARCHAR(254), - requestURL VARCHAR(254), - remoteHost VARCHAR(254), - remoteUser VARCHAR(254), - remoteAddr VARCHAR(254), - protocol VARCHAR(254), - method VARCHAR(254), - serverName VARCHAR(254), - postContent VARCHAR(254), - event_id NUMBER(20) PRIMARY KEY - ); - --- the / suffix may or may not be needed depending on your SQL Client --- Some SQL Clients, e.g. SQuirrel SQL has trouble with the following --- trigger creation command, while SQLPlus (the basic SQL Client which --- ships with Oracle) has no trouble at all. - -CREATE TRIGGER access_event_id_seq_trig - BEFORE INSERT ON access_event - FOR EACH ROW - BEGIN - SELECT access_event_id_seq.NEXTVAL - INTO :NEW.event_id - FROM DUAL; - END access_event_id_seq_trig; -/ - -CREATE TABLE access_event_header - ( - event_id NUMBER(20) NOT NULL, - header_key VARCHAR2(254) NOT NULL, - header_value VARCHAR2(1024), - PRIMARY KEY(event_id, header_key), - FOREIGN KEY (event_id) REFERENCES access_event(event_id) - ); - - - - diff --git a/logback-access/src/main/resources/ch/qos/logback/access/db/script/postgresql.sql b/logback-access/src/main/resources/ch/qos/logback/access/db/script/postgresql.sql deleted file mode 100644 index f0e3430915..0000000000 --- a/logback-access/src/main/resources/ch/qos/logback/access/db/script/postgresql.sql +++ /dev/null @@ -1,39 +0,0 @@ -# Logback: the reliable, generic, fast and flexible logging framework. -# Copyright (C) 1999-2010, QOS.ch. All rights reserved. -# -# See http://logback.qos.ch/license.html for the applicable licensing -# conditions. - -# This SQL script creates the required tables by ch.qos.logback.classic.db.DBAppender -# -# It is intended for PostgreSQL databases. - -DROP TABLE access_event_exception; -DROP SEQUENCE access_event_id_seq; -DROP TABLE access_event; - -CREATE SEQUENCE access_event_id_seq MINVALUE 1 START 1; - -CREATE TABLE access_event - ( - timestmp BIGINT NOT NULL, - requestURI VARCHAR(254), - requestURL VARCHAR(254), - remoteHost VARCHAR(254), - remoteUser VARCHAR(254), - remoteAddr VARCHAR(254), - protocol VARCHAR(254), - method VARCHAR(254), - serverName VARCHAR(254), - postContent VARCHAR(254), - event_id BIGINT DEFAULT nextval('access_event_id_seq') PRIMARY KEY - ); - -CREATE TABLE access_event_header -( - event_id BIGINT NOT NULL, - header_key VARCHAR(254) NOT NULL, - header_value VARCHAR(1024), - PRIMARY KEY(event_id, header_key), - FOREIGN KEY (event_id) REFERENCES access_event(event_id) - ); \ No newline at end of file diff --git a/logback-access/src/test/input/integration/db/mysql-with-driver.xml b/logback-access/src/test/input/integration/db/mysql-with-driver.xml deleted file mode 100644 index 81bfdd89b1..0000000000 --- a/logback-access/src/test/input/integration/db/mysql-with-driver.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - com.mysql.jdbc.Driver - jdbc:mysql://localhost:3306/logback - root - - - - - - - diff --git a/logback-access/src/test/input/integration/db/oracle10g-with-driver.xml b/logback-access/src/test/input/integration/db/oracle10g-with-driver.xml deleted file mode 100644 index bf7dc67b4d..0000000000 --- a/logback-access/src/test/input/integration/db/oracle10g-with-driver.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1522:xe - hr - hr - - - - - - diff --git a/logback-access/src/test/input/integration/db/oracle11g-with-driver.xml b/logback-access/src/test/input/integration/db/oracle11g-with-driver.xml deleted file mode 100644 index 8ed022d986..0000000000 --- a/logback-access/src/test/input/integration/db/oracle11g-with-driver.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521:orcl - SCOTT - SCOTT - - - - - - - diff --git a/logback-access/src/test/input/integration/db/postgresql-with-driver.xml b/logback-access/src/test/input/integration/db/postgresql-with-driver.xml deleted file mode 100644 index 34fc95cb75..0000000000 --- a/logback-access/src/test/input/integration/db/postgresql-with-driver.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - org.postgresql.Driver - jdbc:postgresql://192.168.1.5:5432/test - logback - logback - - - - - - diff --git a/logback-access/src/test/input/integration/db/sqlserver-with-driver.xml b/logback-access/src/test/input/integration/db/sqlserver-with-driver.xml deleted file mode 100644 index 85c0ee20b5..0000000000 --- a/logback-access/src/test/input/integration/db/sqlserver-with-driver.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - com.microsoft.sqlserver.jdbc.SQLServerDriver - jdbc:sqlserver://localhost:1987;databaseName=logback; - logback - logback - - - - - - diff --git a/logback-access/src/test/input/jetty/sifting.xml b/logback-access/src/test/input/jetty/sifting.xml deleted file mode 100644 index b4b89b63dd..0000000000 --- a/logback-access/src/test/input/jetty/sifting.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - uri - REQUEST_URI - NA - - - - - - - - \ No newline at end of file diff --git a/logback-access/src/test/input/joran/conditional/conditionalConsole.xml b/logback-access/src/test/input/joran/conditional/conditionalConsole.xml deleted file mode 100644 index 1ce7b68019..0000000000 --- a/logback-access/src/test/input/joran/conditional/conditionalConsole.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - %h %l %u %user %date "%r" %s %b - - - - - - - - - \ No newline at end of file diff --git a/logback-access/src/test/input/joran/conditional/conditionalConsole_ELSE.xml b/logback-access/src/test/input/joran/conditional/conditionalConsole_ELSE.xml deleted file mode 100644 index 4d3bd85f96..0000000000 --- a/logback-access/src/test/input/joran/conditional/conditionalConsole_ELSE.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - %h %l %u %user %date "%r" %s %b - - - - - - - - - - - - \ No newline at end of file diff --git a/logback-access/src/test/input/joran/defaultLayout.xml b/logback-access/src/test/input/joran/defaultLayout.xml deleted file mode 100644 index d486bf7856..0000000000 --- a/logback-access/src/test/input/joran/defaultLayout.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - %requestMethod - - - - - \ No newline at end of file diff --git a/logback-access/src/test/input/joran/smoke.xml b/logback-access/src/test/input/joran/smoke.xml deleted file mode 100644 index a62cdcedbf..0000000000 --- a/logback-access/src/test/input/joran/smoke.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/logback-access/src/test/input/joran/tomcat/logback-access.xml b/logback-access/src/test/input/joran/tomcat/logback-access.xml deleted file mode 100755 index b4d2a9f8ee..0000000000 --- a/logback-access/src/test/input/joran/tomcat/logback-access.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - %h %l %u %user %date "%r" %s %b - - - - - \ No newline at end of file diff --git a/logback-access/src/test/java/ch/qos/logback/access/AccessTestConstants.java b/logback-access/src/test/java/ch/qos/logback/access/AccessTestConstants.java deleted file mode 100644 index ea5b625b5d..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/AccessTestConstants.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access; - -public class AccessTestConstants { - - public static final String TEST_DIR_PREFIX = "src/test/"; - final static public String INPUT_PREFIX = "src/test/input/"; - final static public String JORAN_INPUT_PREFIX = INPUT_PREFIX + "joran/"; -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/boolex/JaninoEventEvaluatorTest.java b/logback-access/src/test/java/ch/qos/logback/access/boolex/JaninoEventEvaluatorTest.java deleted file mode 100644 index 6f01773882..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/boolex/JaninoEventEvaluatorTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.boolex; - -import ch.qos.logback.access.dummy.DummyRequest; -import ch.qos.logback.access.dummy.DummyResponse; -import ch.qos.logback.access.dummy.DummyServerAdapter; -import ch.qos.logback.access.spi.AccessContext; -import ch.qos.logback.access.spi.AccessEvent; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.boolex.EvaluationException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - -public class JaninoEventEvaluatorTest { - - final String expectedURL1 = "testUrl1"; - final String expectedURL2 = "testUrl2"; - // Context context = new ContextBase(); - JaninoEventEvaluator evaluator; - DummyRequest request; - DummyResponse response; - DummyServerAdapter serverAdapter; - AccessContext accessContext = new AccessContext(); - - @BeforeEach - public void setUp() throws Exception { - evaluator = new JaninoEventEvaluator(); - evaluator.setContext(accessContext); - request = new DummyRequest(); - response = new DummyResponse(); - serverAdapter = new DummyServerAdapter(request, response); - } - - @Test - public void smoke() throws EvaluationException { - evaluator.setExpression("event.getProtocol().equals(\"testProtocol\")"); - evaluator.start(); - IAccessEvent ae = new AccessEvent(accessContext, request, response, serverAdapter); - assertTrue(evaluator.evaluate(ae)); - } - - @Test - public void block() throws EvaluationException { - evaluator.setExpression("String protocol = event.getProtocol();" + "return protocol.equals(\"testProtocol\");"); - evaluator.start(); - IAccessEvent ae = new AccessEvent(accessContext, request, response, serverAdapter); - assertTrue(evaluator.evaluate(ae)); - } - - @Test - public void invalidExpression() throws EvaluationException { - evaluator.setExpression("return true"); - evaluator.start(); - IAccessEvent ae = new AccessEvent(accessContext, request, response, serverAdapter); - try { - evaluator.evaluate(ae); - fail("Was expecting an exception"); - } catch (IllegalStateException e) { - } - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyAccessEventBuilder.java b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyAccessEventBuilder.java deleted file mode 100644 index a63fb4e5b8..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyAccessEventBuilder.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.dummy; - -import ch.qos.logback.access.spi.AccessContext; -import ch.qos.logback.access.spi.AccessEvent; -import ch.qos.logback.access.spi.IAccessEvent; - -public class DummyAccessEventBuilder { - - static public IAccessEvent buildNewAccessEvent() { - DummyRequest request = new DummyRequest(); - DummyResponse response = new DummyResponse(); - DummyServerAdapter adapter = new DummyServerAdapter(request, response); - AccessContext accessContext = new AccessContext(); - - return new AccessEvent(accessContext, request, response, adapter); - } - -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java deleted file mode 100644 index 4e2539c445..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java +++ /dev/null @@ -1,355 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.dummy; - -import ch.qos.logback.access.AccessConstants; - -import jakarta.servlet.*; -import jakarta.servlet.http.*; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.security.Principal; -import java.util.*; - -public class DummyRequest implements HttpServletRequest { - - public final static String DUMMY_CONTENT_STRING = "request contents"; - public final static byte[] DUMMY_CONTENT_BYTES = DUMMY_CONTENT_STRING.getBytes(); - - public static final Map DUMMY_DEFAULT_ATTR_MAP = new HashMap(); - - public static final String DUMMY_RESPONSE_CONTENT_STRING = "response contents"; - public static final byte[] DUMMY_RESPONSE_CONTENT_BYTES = DUMMY_RESPONSE_CONTENT_STRING.getBytes(); - - Hashtable headerMap; - Hashtable parameterMap; - - String uri; - Map attributes; - - static { - DUMMY_DEFAULT_ATTR_MAP.put("testKey", "testKey"); - DUMMY_DEFAULT_ATTR_MAP.put(AccessConstants.LB_INPUT_BUFFER, DUMMY_CONTENT_BYTES); - DUMMY_DEFAULT_ATTR_MAP.put(AccessConstants.LB_OUTPUT_BUFFER, DUMMY_RESPONSE_CONTENT_BYTES); - } - - public DummyRequest() { - headerMap = new Hashtable(); - headerMap.put("headerName1", "headerValue1"); - headerMap.put("headerName2", "headerValue2"); - - parameterMap = new Hashtable(); - parameterMap.put("param1", new String[] { "value1" }); - - attributes = new HashMap(DUMMY_DEFAULT_ATTR_MAP); - } - - public String getAuthType() { - return null; - } - - public String getContextPath() { - return null; - } - - public Cookie[] getCookies() { - Cookie cookie = new Cookie("testName", "testCookie"); - return new Cookie[] { cookie }; - } - - public long getDateHeader(String arg0) { - return 0; - } - - public String getHeader(String key) { - return headerMap.get(key); - } - - @Override - public Enumeration getHeaderNames() { - return headerMap.keys(); - } - - @Override - public Enumeration getHeaders(String arg) { - return null; - } - - public Map getHeaders() { - return headerMap; - } - - public int getIntHeader(String arg0) { - return 0; - } - - public String getMethod() { - return "testMethod"; - } - - public String getPathInfo() { - return null; - } - - public String getPathTranslated() { - return null; - } - - public String getQueryString() { - return null; - } - - public String getRemoteUser() { - return "testUser"; - } - - public String getRequestURI() { - return uri; - } - - public StringBuffer getRequestURL() { - return new StringBuffer(uri); - } - - public String getRequestedSessionId() { - return null; - } - - public String getServletPath() { - return null; - } - - public HttpSession getSession() { - return null; - } - - public HttpSession getSession(boolean arg0) { - return null; - } - - public Principal getUserPrincipal() { - return null; - } - - public boolean isRequestedSessionIdFromCookie() { - return false; - } - - public boolean isRequestedSessionIdFromURL() { - return false; - } - - public boolean isRequestedSessionIdFromUrl() { - return false; - } - - public boolean authenticate(HttpServletResponse response) throws IOException, ServletException { - return false; // To change body of implemented methods use File | Settings | File Templates. - } - - public void login(String username, String password) throws ServletException { - // To change body of implemented methods use File | Settings | File Templates. - } - - public void logout() throws ServletException { - // To change body of implemented methods use File | Settings | File Templates. - } - - public Collection getParts() throws IOException, IllegalStateException, ServletException { - return null; // To change body of implemented methods use File | Settings | File Templates. - } - - public Part getPart(String name) throws IOException, IllegalStateException, ServletException { - return null; // To change body of implemented methods use File | Settings | File Templates. - } - - public boolean isRequestedSessionIdValid() { - return false; - } - - public boolean isUserInRole(String arg0) { - return false; - } - - public Object getAttribute(String key) { - return attributes.get(key); - } - - public Enumeration getAttributeNames() { - return Collections.enumeration(attributes.keySet()); - } - - public String getCharacterEncoding() { - return null; - } - - public int getContentLength() { - return 0; - } - - public String getContentType() { - return null; - } - - public ServletInputStream getInputStream() throws IOException { - return null; - } - - public String getLocalAddr() { - return null; - } - - public String getLocalName() { - return null; - } - - public int getLocalPort() { - return 11; - } - - public ServletContext getServletContext() { - return null; // To change body of implemented methods use File | Settings | File Templates. - } - - public AsyncContext startAsync() { - return null; // To change body of implemented methods use File | Settings | File Templates. - } - - public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) { - return null; // To change body of implemented methods use File | Settings | File Templates. - } - - public boolean isAsyncStarted() { - return false; // To change body of implemented methods use File | Settings | File Templates. - } - - public boolean isAsyncSupported() { - return false; // To change body of implemented methods use File | Settings | File Templates. - } - - public AsyncContext getAsyncContext() { - return null; // To change body of implemented methods use File | Settings | File Templates. - } - - public DispatcherType getDispatcherType() { - return null; // To change body of implemented methods use File | Settings | File Templates. - } - - public Locale getLocale() { - return null; - } - - @Override - public Enumeration getLocales() { - return null; - } - - public String getParameter(String arg) { - String[] stringArray = parameterMap.get(arg); - if (stringArray == null || stringArray.length == 0) - return null; - else - return stringArray[0]; - } - - @Override - public Map getParameterMap() { - return parameterMap; - } - - public Enumeration getParameterNames() { - return parameterMap.keys(); - // return Collections.enumeration(parameterMap.keySet()); - } - - public String[] getParameterValues(String arg) { - return parameterMap.get(arg); - } - - public String getProtocol() { - return "testProtocol"; - } - - public BufferedReader getReader() throws IOException { - return null; - } - - public String getRealPath(String arg0) { - return null; - } - - public String getRemoteAddr() { - return "testRemoteAddress"; - } - - public String getRemoteHost() { - return "testHost"; - } - - public int getRemotePort() { - return 0; - } - - public RequestDispatcher getRequestDispatcher(String arg0) { - return null; - } - - public String getScheme() { - return null; - } - - public String getServerName() { - return "testServerName"; - } - - public int getServerPort() { - return 0; - } - - public boolean isSecure() { - return false; - } - - public void removeAttribute(String arg0) { - } - - public void setAttribute(String name, Object value) { - attributes.put(name, value); - } - - public void setCharacterEncoding(String arg0) throws UnsupportedEncodingException { - } - - public void setRequestUri(String uri) { - this.uri = uri; - } - - @Override - public long getContentLengthLong() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public String changeSessionId() { - return null; - } - - @Override - public T upgrade(Class httpUpgradeHandlerClass) - throws IOException, ServletException { - return null; - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java deleted file mode 100644 index 4d5a055206..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java +++ /dev/null @@ -1,188 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.dummy; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.*; - -import jakarta.servlet.ServletOutputStream; -import jakarta.servlet.http.Cookie; -import jakarta.servlet.http.HttpServletResponse; - -public class DummyResponse implements HttpServletResponse { - - public static final int DUMMY_DEFAULT_STATUS = 200; - public static final int DUMMY_DEFAULT_CONTENT_COUNT = 1000; - public static final Map DUMMY_DEFAULT_HDEADER_MAP = new HashMap();; - - static { - DUMMY_DEFAULT_HDEADER_MAP.put("headerName1", "headerValue1"); - DUMMY_DEFAULT_HDEADER_MAP.put("headerName2", "headerValue2"); - } - - int status = DUMMY_DEFAULT_STATUS; - public Map headerMap; - - String characterEncoding = null; - ServletOutputStream outputStream = null; - - public DummyResponse() { - headerMap = DUMMY_DEFAULT_HDEADER_MAP; - } - - public void addCookie(Cookie arg0) { - } - - public void addDateHeader(String arg0, long arg1) { - } - - public void addHeader(String arg0, String arg1) { - } - - public void addIntHeader(String arg0, int arg1) { - } - - public boolean containsHeader(String arg0) { - return false; - } - - public String encodeRedirectURL(String arg0) { - return null; - } - - public String encodeRedirectUrl(String arg0) { - return null; - } - - public String encodeURL(String arg0) { - return null; - } - - public String encodeUrl(String arg0) { - return null; - } - - public void sendError(int arg0) throws IOException { - } - - public void sendError(int arg0, String arg1) throws IOException { - } - - public void sendRedirect(String arg0) throws IOException { - } - - public void setDateHeader(String arg0, long arg1) { - } - - public void setHeader(String arg0, String arg1) { - } - - public void setIntHeader(String arg0, int arg1) { - } - - public void setStatus(int arg0, String arg1) { - } - - public void flushBuffer() throws IOException { - } - - public int getBufferSize() { - return 0; - } - - public String getCharacterEncoding() { - return characterEncoding; - } - - public String getContentType() { - return null; - } - - public Locale getLocale() { - return null; - } - - public ServletOutputStream getOutputStream() throws IOException { - return outputStream; - } - - public void setOutputStream(ServletOutputStream outputStream) { - this.outputStream = outputStream; - } - - public PrintWriter getWriter() throws IOException { - return null; - } - - public boolean isCommitted() { - return false; - } - - public void reset() { - } - - public void resetBuffer() { - } - - public void setBufferSize(int arg0) { - } - - public void setCharacterEncoding(String characterEncoding) { - this.characterEncoding = characterEncoding; - } - - public void setContentLength(int arg0) { - } - - public void setContentType(String arg0) { - } - - public void setLocale(Locale arg0) { - } - - public String getHeader(String key) { - return headerMap.get(key); - } - - public Collection getHeaders(String name) { - String val = headerMap.get(name); - List list = new ArrayList(); - if (val != null) - list.add(val); - return list; - } - - public Collection getHeaderNames() { - return headerMap.keySet(); - } - - public long getContentCount() { - return DUMMY_DEFAULT_CONTENT_COUNT; - } - - public int getStatus() { - return status; - } - - public void setStatus(int status) { - this.status = status; - } - - @Override - public void setContentLengthLong(long length) { - // TODO Auto-generated method stub - } - -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServerAdapter.java b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServerAdapter.java deleted file mode 100644 index 7af921da30..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServerAdapter.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.dummy; - -import ch.qos.logback.access.spi.ServerAdapter; - -import java.util.Map; - -public class DummyServerAdapter implements ServerAdapter { - - DummyRequest request; - DummyResponse response; - - public DummyServerAdapter(DummyRequest dummyRequest, DummyResponse dummyResponse) { - this.request = dummyRequest; - this.response = dummyResponse; - } - - public long getContentLength() { - return response.getContentCount(); - } - - public int getStatusCode() { - return response.getStatus(); - } - - public long getRequestTimestamp() { - return -1; - } - - public Map buildResponseHeaderMap() { - return response.headerMap; - } - -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServletOutputStream.java b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServletOutputStream.java deleted file mode 100644 index 30a4115ed2..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServletOutputStream.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.dummy; - -import jakarta.servlet.ServletOutputStream; -import jakarta.servlet.WriteListener; - -import java.io.IOException; -import java.io.OutputStream; - -public class DummyServletOutputStream extends ServletOutputStream { - - private final OutputStream targetStream; - - public DummyServletOutputStream(OutputStream targetStream) { - this.targetStream = targetStream; - } - - @Override - public void write(int b) throws IOException { - this.targetStream.write(b); - } - - public void flush() throws IOException { - super.flush(); - this.targetStream.flush(); - } - - public void close() throws IOException { - super.close(); - this.targetStream.close(); - } - - @Override - public boolean isReady() { - // TODO Auto-generated method stub - return false; - } - - @Override - public void setWriteListener(WriteListener listener) { - // TODO Auto-generated method stub - - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/filter/StatsByDayTest.java b/logback-access/src/test/java/ch/qos/logback/access/filter/StatsByDayTest.java deleted file mode 100644 index ad6807685b..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/filter/StatsByDayTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.filter; - -import ch.qos.logback.core.util.TimeUtil; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class StatsByDayTest { - - @Test - public void testBasic() { - // Tue Nov 21 18:05:36 CET 2006 - long now = 1164128736369L; - StatsByDay statsByDay = new StatsByDay(now); - - int total = 0; - // test fresh start - statsByDay.update(now, 0); - assertEquals(0, statsByDay.getLastCount()); - assertEquals(0, statsByDay.getAverage(), 0.01); - - total++; - statsByDay.update(now, total); - assertEquals(0, statsByDay.getLastCount()); - assertEquals(0.0, statsByDay.getAverage(), 0.01); - - long nextDay0 = TimeUtil.computeStartOfNextDay(now); - nextDay0 += 99; - - // there should be one event the next day, avg should also be 1 - statsByDay.update(nextDay0, total); - assertEquals(1.0, statsByDay.getLastCount(), 0.01); - assertEquals(1.0, statsByDay.getAverage(), 0.01); - - total += 2; - - statsByDay.update(nextDay0, total); - assertEquals(1, statsByDay.getLastCount()); - assertEquals(1.0, statsByDay.getAverage(), 0.01); - - long nextDay1 = TimeUtil.computeStartOfNextDay(nextDay0) + 6747; - statsByDay.update(nextDay1, total); - assertEquals(2, statsByDay.getLastCount()); - assertEquals(1.5, statsByDay.getAverage(), 0.01); - - nextDay1 += 4444; - total += 4; - - statsByDay.update(nextDay1, total); - // values should remain unchanged - assertEquals(2, statsByDay.getLastCount()); - assertEquals(1.5, statsByDay.getAverage(), 0.01); - - long nextDay2 = TimeUtil.computeStartOfNextDay(nextDay1) + 11177; - - statsByDay.update(nextDay2, total); - // values should remain unchanged - assertEquals(4, statsByDay.getLastCount()); - assertEquals(7.0 / 3, statsByDay.getAverage(), 0.01); - } - -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java deleted file mode 100644 index e9bfb2c602..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.jetty; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.access.spi.Util; -import ch.qos.logback.access.testUtil.NotifyingListAppender; -import ch.qos.logback.core.testUtil.RandomUtil; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.concurrent.TimeUnit; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -public class JettyBasicTest { - - static RequestLogImpl REQUEST_LOG_IMPL; - static JettyFixtureWithListAndConsoleAppenders JETTY_FIXTURE; - - private static final int TIMEOUT = 5; - static int RANDOM_SERVER_PORT = RandomUtil.getRandomServerPort(); - - @BeforeAll - static public void startServer() throws Exception { - REQUEST_LOG_IMPL = new RequestLogImpl(); - JETTY_FIXTURE = new JettyFixtureWithListAndConsoleAppenders(REQUEST_LOG_IMPL, RANDOM_SERVER_PORT); - JETTY_FIXTURE.start(); - } - - @AfterAll - static public void stopServer() throws Exception { - if (JETTY_FIXTURE != null) { - JETTY_FIXTURE.stop(); - } - } - - @Test - public void getRequest() throws Exception { - URL url = new URL("http://localhost:" + RANDOM_SERVER_PORT + "/"); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoInput(true); - - String result = Util.readToString(connection.getInputStream()); - - assertEquals("hello world", result); - - NotifyingListAppender listAppender = (NotifyingListAppender) REQUEST_LOG_IMPL.getAppender("list"); - listAppender.list.clear(); - } - - @Test - public void eventGoesToAppenders() throws Exception { - URL url = new URL(JETTY_FIXTURE.getUrl()); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoInput(true); - - String result = Util.readToString(connection.getInputStream()); - - assertEquals("hello world", result); - - NotifyingListAppender listAppender = (NotifyingListAppender) REQUEST_LOG_IMPL.getAppender("list"); - IAccessEvent event = listAppender.list.poll(TIMEOUT, TimeUnit.SECONDS); - assertNotNull(event, "No events received"); - - assertEquals("127.0.0.1", event.getRemoteHost()); - assertEquals("localhost", event.getServerName()); - listAppender.list.clear(); - } - - @Test - public void postContentConverter() throws Exception { - URL url = new URL(JETTY_FIXTURE.getUrl()); - String msg = "test message"; - - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - // this line is necessary to make the stream aware of when the message is - // over. - connection.setFixedLengthStreamingMode(msg.getBytes().length); - ((HttpURLConnection) connection).setRequestMethod("POST"); - connection.setDoOutput(true); - connection.setDoInput(true); - connection.setUseCaches(false); - connection.setRequestProperty("Content-Type", "text/plain"); - - PrintWriter output = new PrintWriter(new OutputStreamWriter(connection.getOutputStream())); - output.print(msg); - output.flush(); - output.close(); - - // StatusPrinter.print(requestLogImpl.getStatusManager()); - - NotifyingListAppender listAppender = (NotifyingListAppender) REQUEST_LOG_IMPL.getAppender("list"); - - IAccessEvent event = listAppender.list.poll(TIMEOUT, TimeUnit.SECONDS); - assertNotNull(event, "No events received"); - - // we should test the contents of the requests - // assertEquals(msg, event.getRequestContent()); - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureBase.java b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureBase.java deleted file mode 100644 index 0e546d6da7..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureBase.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.jetty; - -import java.io.IOException; -import java.io.Writer; -import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.Handler; -import org.eclipse.jetty.server.handler.AbstractHandler; - -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - - -public class JettyFixtureBase { - final protected RequestLogImpl requestLogImpl; - protected Handler handler = new BasicHandler(); - private final int port; - Server server; - protected String url; - - public JettyFixtureBase(RequestLogImpl impl, int port) { - requestLogImpl = impl; - this.port = port; - url = "http://localhost:" + port + "/"; - } - - public String getName() { - return "Jetty Test Setup"; - } - - public String getUrl() { - return url; - } - - public void start() throws Exception { - server = new Server(port); - - server.setRequestLog(requestLogImpl); - configureRequestLogImpl(); - - server.setHandler(getRequestHandler()); - server.start(); - } - - public void stop() throws Exception { - server.stop(); - server = null; - } - - protected void configureRequestLogImpl() { - requestLogImpl.start(); - } - - protected Handler getRequestHandler() { - return handler; - } - - class BasicHandler extends AbstractHandler { - public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - response.setCharacterEncoding("UTF-8"); - response.setContentType("text/plain"); - Writer writer = response.getWriter(); - writer.write("hello world"); - writer.flush(); - baseRequest.setHandled(true); - } - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureWithListAndConsoleAppenders.java b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureWithListAndConsoleAppenders.java deleted file mode 100644 index 741f5f75ce..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureWithListAndConsoleAppenders.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.jetty; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.access.PatternLayoutEncoder; -import ch.qos.logback.access.testUtil.NotifyingListAppender; -import ch.qos.logback.core.ConsoleAppender; - -public class JettyFixtureWithListAndConsoleAppenders extends JettyFixtureBase { - - public JettyFixtureWithListAndConsoleAppenders(RequestLogImpl impl, int port) { - super(impl, port); - url = "http://localhost:" + port + "/"; - } - - public void start() throws Exception { - super.start(); - Thread.yield(); - } - - public void stop() throws Exception { - super.stop(); - Thread.sleep(500); - } - - @Override - protected void configureRequestLogImpl() { - NotifyingListAppender appender = new NotifyingListAppender(); - appender.setContext(requestLogImpl); - appender.setName("list"); - appender.start(); - - ConsoleAppender console = new ConsoleAppender(); - console.setContext(requestLogImpl); - console.setName("console"); - PatternLayoutEncoder layout = new PatternLayoutEncoder(); - layout.setContext(requestLogImpl); - layout.setPattern("%date %server %clientHost"); - console.setEncoder(layout); - layout.start(); - console.start(); - - requestLogImpl.addAppender(appender); - requestLogImpl.addAppender(console); - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java b/logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java deleted file mode 100644 index b22bb79d67..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.joran; - -import ch.qos.logback.access.AccessTestConstants; -import ch.qos.logback.access.spi.AccessContext; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.ConsoleAppender; -import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.read.ListAppender; -import ch.qos.logback.core.testUtil.CoreTestConstants; -import ch.qos.logback.core.testUtil.RandomUtil; -import ch.qos.logback.core.status.testUtil.StatusChecker; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * @author Ceki Gülcü - */ -@Disabled -public class ConditionalTest { - - AccessContext context = new AccessContext(); - StatusChecker checker = new StatusChecker(context); - - int diff = RandomUtil.getPositiveInt(); - String randomOutputDir = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "/"; - - @BeforeEach - public void setUp() { - InetAddress localhost = null; - try { - localhost = InetAddress.getLocalHost(); - context.putProperty("aHost", localhost.getHostName()); - } catch (UnknownHostException e) { - e.printStackTrace(); - } - } - - void configure(String file) throws JoranException { - JoranConfigurator jc = new JoranConfigurator(); - jc.setContext(context); - jc.doConfigure(file); - } - - @Test - public void conditionalConsoleApp_IF_THEN_True() throws JoranException, UnknownHostException { - configure(AccessTestConstants.TEST_DIR_PREFIX + "input/joran/conditional/conditionalConsole.xml"); - ConsoleAppender consoleAppender = (ConsoleAppender) context.getAppender("CON"); - assertNotNull(consoleAppender); - assertTrue(checker.isErrorFree(0)); - } - - @Test - public void conditionalConsoleApp_IF_THEN_False() throws JoranException, IOException, InterruptedException { - context.putProperty("aHost", null); - configure(AccessTestConstants.TEST_DIR_PREFIX + "input/joran/conditional/conditionalConsole.xml"); - - ConsoleAppender consoleAppender = (ConsoleAppender) context.getAppender("CON"); - assertNull(consoleAppender); - - StatusChecker checker = new StatusChecker(context); - assertTrue(checker.isErrorFree(0)); - } - - @Test - public void conditionalConsoleApp_ELSE() throws JoranException, IOException, InterruptedException { - configure(AccessTestConstants.TEST_DIR_PREFIX + "input/joran/conditional/conditionalConsole_ELSE.xml"); - ConsoleAppender consoleAppender = (ConsoleAppender) context.getAppender("CON"); - assertNull(consoleAppender); - - ListAppender listAppender = (ListAppender) context.getAppender("LIST"); - assertNotNull(listAppender); - assertTrue(checker.isErrorFree(0)); - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/joran/JoranConfiguratorTest.java b/logback-access/src/test/java/ch/qos/logback/access/joran/JoranConfiguratorTest.java deleted file mode 100644 index eb6e1fe215..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/joran/JoranConfiguratorTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.joran; - -import ch.qos.logback.access.AccessTestConstants; -import ch.qos.logback.access.dummy.DummyAccessEventBuilder; -import ch.qos.logback.access.spi.AccessContext; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.read.ListAppender; -import ch.qos.logback.core.testUtil.StringListAppender; -import ch.qos.logback.core.util.StatusPrinter; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class JoranConfiguratorTest { - - AccessContext context = new AccessContext(); - - @BeforeEach - public void setUp() throws Exception { - } - - @AfterEach - public void tearDown() throws Exception { - } - - void configure(String file) throws JoranException { - JoranConfigurator jc = new JoranConfigurator(); - jc.setContext(context); - jc.doConfigure(file); - } - - @Test - public void smoke() throws Exception { - configure(AccessTestConstants.TEST_DIR_PREFIX + "input/joran/smoke.xml"); - StatusPrinter.print(context); - ListAppender listAppender = (ListAppender) context.getAppender("LIST"); - assertNotNull(listAppender); - IAccessEvent event = DummyAccessEventBuilder.buildNewAccessEvent(); - listAppender.doAppend(event); - - assertEquals(1, listAppender.list.size()); - - assertEquals(1, listAppender.list.size()); - IAccessEvent ae = listAppender.list.get(0); - assertNotNull(ae); - } - - @Test - public void defaultLayout() throws Exception { - configure(AccessTestConstants.TEST_DIR_PREFIX + "input/joran/defaultLayout.xml"); - StringListAppender listAppender = (StringListAppender) context - .getAppender("STR_LIST"); - IAccessEvent event = DummyAccessEventBuilder.buildNewAccessEvent(); - listAppender.doAppend(event); - assertEquals(1, listAppender.strList.size()); - // the result contains a line separator at the end - assertTrue(listAppender.strList.get(0).startsWith("testMethod")); - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/net/NOPOutputStream.java b/logback-access/src/test/java/ch/qos/logback/access/net/NOPOutputStream.java deleted file mode 100644 index bcb24588ea..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/net/NOPOutputStream.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net; - -import java.io.IOException; -import java.io.OutputStream; - -public class NOPOutputStream extends OutputStream { - - @Override - public void write(int b) throws IOException { - // do nothing - - } - -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/net/SerializationPerfTest.java b/logback-access/src/test/java/ch/qos/logback/access/net/SerializationPerfTest.java deleted file mode 100644 index c1075e3184..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/net/SerializationPerfTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net; - -import java.io.IOException; -import java.io.ObjectOutputStream; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.access.dummy.DummyAccessEventBuilder; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.fail; - -@Disabled -public class SerializationPerfTest { - - ObjectOutputStream oos; - - int loopNumber = 10000; - int resetFrequency = 100; - int pauseFrequency = 10; - long pauseLengthInMillis = 20; - - @BeforeEach - public void setUp() throws Exception { - oos = new ObjectOutputStream(new NOPOutputStream()); - } - - @AfterEach - public void tearDown() throws Exception { - oos.close(); - oos = null; - } - - @Test - public void test1() throws Exception { - // first run for just in time compiler - int resetCounter = 0; - int pauseCounter = 0; - for (int i = 0; i < loopNumber; i++) { - try { - IAccessEvent ae = DummyAccessEventBuilder.buildNewAccessEvent(); - // average time for the next method: 5000 nanos - ae.prepareForDeferredProcessing(); - oos.writeObject(ae); - oos.flush(); - if (++resetCounter >= resetFrequency) { - oos.reset(); - resetCounter = 0; - } - if (++pauseCounter >= pauseFrequency) { - Thread.sleep(pauseLengthInMillis); - pauseCounter = 0; - } - - } catch (IOException ex) { - fail(ex.getMessage()); - } - } - - // second run - Long t1; - Long t2; - Long total = 0L; - resetCounter = 0; - pauseCounter = 0; - // System.out.println("Beginning measured run"); - for (int i = 0; i < loopNumber; i++) { - try { - IAccessEvent ae = DummyAccessEventBuilder.buildNewAccessEvent(); - t1 = System.nanoTime(); - // average length of the next method: 4000 nanos - ae.prepareForDeferredProcessing(); - oos.writeObject(ae); - oos.flush(); - t2 = System.nanoTime(); - total += (t2 - t1); - if (++resetCounter >= resetFrequency) { - oos.reset(); - resetCounter = 0; - } - if (++pauseCounter >= pauseFrequency) { - Thread.sleep(pauseLengthInMillis); - pauseCounter = 0; - } - } catch (IOException ex) { - fail(ex.getMessage()); - } - } - - total /= (1000);// nanos -> micros - System.out.println( - "Loop done : average time = " + total / loopNumber + " microsecs after " + loopNumber + " writes."); - // average time: 26-30 microsec = 0.030 millis - } - -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/net/URLEvaluatorTest.java b/logback-access/src/test/java/ch/qos/logback/access/net/URLEvaluatorTest.java deleted file mode 100644 index 64f330a3b4..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/net/URLEvaluatorTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net; - -import ch.qos.logback.access.dummy.DummyRequest; -import ch.qos.logback.access.dummy.DummyResponse; -import ch.qos.logback.access.dummy.DummyServerAdapter; -import ch.qos.logback.access.spi.AccessContext; -import ch.qos.logback.access.spi.AccessEvent; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.boolex.EvaluationException; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class URLEvaluatorTest { - - final String expectedURL1 = "testUrl1"; - final String expectedURL2 = "testUrl2"; - AccessContext accessContext = new AccessContext(); - URLEvaluator evaluator; - DummyRequest request; - DummyResponse response; - DummyServerAdapter serverAdapter; - - @BeforeEach - public void setUp() throws Exception { - evaluator = new URLEvaluator(); - evaluator.setContext(accessContext); - evaluator.addURL(expectedURL1); - evaluator.start(); - request = new DummyRequest(); - response = new DummyResponse(); - serverAdapter = new DummyServerAdapter(request, response); - } - - @AfterEach - public void tearDown() throws Exception { - evaluator.stop(); - evaluator = null; - request = null; - response = null; - serverAdapter = null; - accessContext = null; - } - - @Test - public void testExpectFalse() throws EvaluationException { - request.setRequestUri("test"); - IAccessEvent ae = new AccessEvent(accessContext, request, response, serverAdapter); - assertFalse(evaluator.evaluate(ae)); - } - - @Test - public void testExpectTrue() throws EvaluationException { - request.setRequestUri(expectedURL1); - IAccessEvent ae = new AccessEvent(accessContext, request, response, serverAdapter); - assertTrue(evaluator.evaluate(ae)); - } - - @Test - public void testExpectTrueMultiple() throws EvaluationException { - evaluator.addURL(expectedURL2); - request.setRequestUri(expectedURL2); - IAccessEvent ae = new AccessEvent(accessContext, request, response, serverAdapter); - assertTrue(evaluator.evaluate(ae)); - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/pattern/ConverterTest.java b/logback-access/src/test/java/ch/qos/logback/access/pattern/ConverterTest.java deleted file mode 100644 index 07a4875f73..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/pattern/ConverterTest.java +++ /dev/null @@ -1,226 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.pattern; - - -import ch.qos.logback.access.dummy.DummyRequest; -import ch.qos.logback.access.dummy.DummyResponse; -import ch.qos.logback.access.dummy.DummyServerAdapter; -import ch.qos.logback.access.spi.AccessContext; -import ch.qos.logback.access.spi.AccessEvent; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.model.TimestampModel; -import jakarta.servlet.http.Cookie; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class ConverterTest { - - AccessEvent event; - DummyRequest request = new DummyRequest(); - DummyResponse response = new DummyResponse(); - AccessContext accessContext = new AccessContext(); - - Locale defaultLocale = Locale.getDefault(); - - @BeforeEach - public void setUp() throws Exception { - event = createEvent(); - } - - @AfterEach - public void tearDown() throws Exception { - event = null; - request = null; - response = null; - Locale.setDefault(defaultLocale); - } - - @Test - public void testContentLengthConverter() { - ContentLengthConverter converter = new ContentLengthConverter(); - converter.start(); - String result = converter.convert(event); - assertEquals(Long.toString(event.getServerAdapter().getContentLength()), result); - } - - @Test - public void testDateConverter() { - DateConverter converter = new DateConverter(); - converter.start(); - String result = converter.convert(event); - assertEquals(converter.cachingDateFormatter.format(event.getTimeStamp()), result); - } - - @Test - public void testDateConverter_AU_locale() { - DateConverter converter = new DateConverter(); - List optionsList = Lists.list(CoreConstants.CLF_DATE_PATTERN, "Australia/Sydney", "en-AU"); - - converter.setOptionList(optionsList); - converter.start(); - Instant instant = Instant.parse("2022-10-21T10:30:20.800Z"); - - System.out.println(instant.toEpochMilli()); - - event.setTimeStamp(instant.toEpochMilli()); - String result = converter.convert(event); - assertEquals("21/Oct/2022:21:30:20 +1100", result); - System.out.println(result); - - assertEquals(converter.cachingDateFormatter.format(event.getTimeStamp()), result); - } - - - public void testLineLocalPortConverter() { - LocalPortConverter converter = new LocalPortConverter(); - converter.start(); - String result = converter.convert(event); - assertEquals(Integer.toString(request.getLocalPort()), result); - } - - @Test - public void testRemoteHostConverter() { - RemoteHostConverter converter = new RemoteHostConverter(); - converter.start(); - String result = converter.convert(event); - assertEquals(request.getRemoteHost(), result); - } - - @Test - public void testRemoteIPAddressConverter() { - RemoteIPAddressConverter converter = new RemoteIPAddressConverter(); - converter.start(); - String result = converter.convert(event); - assertEquals(request.getRemoteAddr(), result); - } - - @Test - public void testRemoteUserConverter() { - RemoteUserConverter converter = new RemoteUserConverter(); - converter.start(); - String result = converter.convert(event); - assertEquals(request.getRemoteUser(), result); - } - - @Test - public void testRequestAttributeConverter() { - RequestAttributeConverter converter = new RequestAttributeConverter(); - List optionList = new ArrayList(); - optionList.add("testKey"); - converter.setOptionList(optionList); - converter.start(); - String result = converter.convert(event); - assertEquals(request.getAttribute("testKey"), result); - } - - @Test - public void testRequestCookieConverter() { - RequestCookieConverter converter = new RequestCookieConverter(); - List optionList = new ArrayList(); - optionList.add("testName"); - converter.setOptionList(optionList); - converter.start(); - String result = converter.convert(event); - Cookie cookie = request.getCookies()[0]; - assertEquals(cookie.getValue(), result); - } - - @Test - public void testRequestHeaderConverter() { - RequestHeaderConverter converter = new RequestHeaderConverter(); - List optionList = new ArrayList(); - optionList.add("headerName1"); - converter.setOptionList(optionList); - converter.start(); - String result = converter.convert(event); - assertEquals(request.getHeader("headerName1"), result); - } - - @Test - public void testRequestMethodConverter() { - RequestMethodConverter converter = new RequestMethodConverter(); - converter.start(); - String result = converter.convert(event); - assertEquals(request.getMethod(), result); - } - - @Test - public void testRequestProtocolConverter() { - RequestProtocolConverter converter = new RequestProtocolConverter(); - converter.start(); - String result = converter.convert(event); - assertEquals(request.getProtocol(), result); - } - - @Test - public void testRequestURIConverter() { - RequestURIConverter converter = new RequestURIConverter(); - converter.start(); - String result = converter.convert(event); - assertEquals(request.getRequestURI(), result); - } - - @Test - public void testRequestURLConverter() { - RequestURLConverter converter = new RequestURLConverter(); - converter.start(); - String result = converter.convert(event); - String expected = request.getMethod() + " " + request.getRequestURI() + " " + request.getProtocol(); - assertEquals(expected, result); - } - - @Test - public void testResponseHeaderConverter() { - ResponseHeaderConverter converter = new ResponseHeaderConverter(); - List optionList = new ArrayList(); - optionList.add("headerName1"); - converter.setOptionList(optionList); - converter.start(); - String result = converter.convert(event); - assertEquals(request.getHeader("headerName1"), result); - } - - @Test - public void testServerNameConverter() { - ServerNameConverter converter = new ServerNameConverter(); - converter.start(); - String result = converter.convert(event); - assertEquals(request.getServerName(), result); - } - - @Test - public void testStatusCodeConverter() { - StatusCodeConverter converter = new StatusCodeConverter(); - converter.start(); - String result = converter.convert(event); - assertEquals(Integer.toString(event.getServerAdapter().getStatusCode()), result); - } - - private AccessEvent createEvent() { - DummyServerAdapter dummyAdapter = new DummyServerAdapter(request, response); - return new AccessEvent(accessContext, request, response, dummyAdapter); - } - -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/servlet/TeeFilterTest.java b/logback-access/src/test/java/ch/qos/logback/access/servlet/TeeFilterTest.java deleted file mode 100644 index 33fcfdb2ca..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/servlet/TeeFilterTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.servlet; - -import org.junit.jupiter.api.Test; - -import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - - -public class TeeFilterTest { - - @Test - public void extractNameList() { - assertEquals(Arrays.asList(new String[] { "a" }), TeeFilter.extractNameList("a")); - assertEquals(Arrays.asList(new String[] { "a", "b" }), TeeFilter.extractNameList("a, b")); - assertEquals(Arrays.asList(new String[] { "a", "b" }), TeeFilter.extractNameList("a; b")); - assertEquals(Arrays.asList(new String[] { "a", "b", "c" }), TeeFilter.extractNameList("a; b, c")); - } - - @Test - public void defaultCase() { - assertTrue(TeeFilter.computeActivation("somehost", "", "")); - assertTrue(TeeFilter.computeActivation("somehost", null, null)); - } - - @Test - public void withIncludesOnly() { - assertTrue(TeeFilter.computeActivation("a", "a", null)); - assertTrue(TeeFilter.computeActivation("a", "a, b", null)); - assertFalse(TeeFilter.computeActivation("a", "b", null)); - assertFalse(TeeFilter.computeActivation("a", "b, c", null)); - } - - @Test - public void withExcludesOnly() { - assertFalse(TeeFilter.computeActivation("a", null, "a")); - assertFalse(TeeFilter.computeActivation("a", null, "a, b")); - assertTrue(TeeFilter.computeActivation("a", null, "b")); - assertTrue(TeeFilter.computeActivation("a", null, "b, c")); - } - - @Test - public void withIncludesAndExcludes() { - assertFalse(TeeFilter.computeActivation("a", "a", "a")); - assertTrue(TeeFilter.computeActivation("a", "a", "b")); - assertFalse(TeeFilter.computeActivation("a", "b", "a")); - assertFalse(TeeFilter.computeActivation("a", "b", "b")); - - } - -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/servlet/TeeHttpServletResponseTest.java b/logback-access/src/test/java/ch/qos/logback/access/servlet/TeeHttpServletResponseTest.java deleted file mode 100644 index 74fd788133..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/servlet/TeeHttpServletResponseTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.servlet; - -import ch.qos.logback.access.dummy.DummyResponse; -import ch.qos.logback.access.dummy.DummyServletOutputStream; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; - -public class TeeHttpServletResponseTest { - - public static Stream inputValues() { - return Stream.of( - Arguments.of( "utf-8", "G\u00FClc\u00FC", - new byte[] { (byte) 0x47, (byte) 0xC3, (byte) 0xBC, (byte) 0x6C, (byte) 0x63, (byte) 0xC3, - (byte) 0xBC}), - Arguments.of("iso-8859-1", "G\u00FClc\u00FC", - new byte[] { (byte) 0x47, (byte) 0xFC, (byte) 0x6C, (byte) 0x63, (byte) 0xFC})); - } - - @ParameterizedTest - @MethodSource("inputValues") - public void testWriterEncoding(String characterEncoding, String testString, byte[] expectedBytes) throws IOException { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - - DummyResponse dummyResponse = new DummyResponse(); - dummyResponse.setCharacterEncoding(characterEncoding); - dummyResponse.setOutputStream(new DummyServletOutputStream(byteArrayOutputStream)); - - TeeHttpServletResponse teeServletResponse = new TeeHttpServletResponse(dummyResponse); - - PrintWriter writer = teeServletResponse.getWriter(); - writer.write(testString); - writer.flush(); - - assertArrayEquals(expectedBytes, byteArrayOutputStream.toByteArray()); - } - -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/sift/SiftingAppenderTest.java b/logback-access/src/test/java/ch/qos/logback/access/sift/SiftingAppenderTest.java deleted file mode 100644 index 2fbd2fb750..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/sift/SiftingAppenderTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.sift; - -import ch.qos.logback.access.jetty.JettyFixtureBase; -import ch.qos.logback.access.jetty.RequestLogImpl; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.access.spi.Util; -import ch.qos.logback.core.read.ListAppender; -import ch.qos.logback.core.testUtil.RandomUtil; -import ch.qos.logback.core.util.StatusPrinter; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.LinkedHashSet; -import java.util.Set; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class SiftingAppenderTest { - static final String PREFIX = "src/test/input/jetty/"; - static int RANDOM_SERVER_PORT = RandomUtil.getRandomServerPort(); - - JettyFixtureBase jettyFixture; - RequestLogImpl rli = new RequestLogImpl(); - - @BeforeEach - public void startServer() throws Exception { - jettyFixture = new JettyFixtureBase(rli, RANDOM_SERVER_PORT); - } - - @AfterEach - public void stopServer() throws Exception { - if (jettyFixture != null) { - jettyFixture.stop(); - } - } - - @Test - public void invokingDifferentPathShouldBeSiftedAccordingly() throws Exception { - rli.setFileName(PREFIX + "sifting.xml"); - jettyFixture.start(); - invokeServer("/"); - invokeServer("/x"); - invokeServer("/x"); - invokeServer("/y"); - - StatusPrinter.print(rli); - SiftingAppender siftingAppender = (SiftingAppender) rli.getAppender("SIFTING"); - Set keySet = siftingAppender.getAppenderTracker().allKeys(); - assertEquals(3, keySet.size()); - - Set witnessSet = new LinkedHashSet(); - witnessSet.add("NA"); - witnessSet.add("x"); - witnessSet.add("y"); - assertEquals(witnessSet, keySet); - - check(siftingAppender, "NA", 1); - check(siftingAppender, "x", 2); - check(siftingAppender, "y", 1); - } - - private void check(SiftingAppender siftingAppender, String key, int expectedCount) { - ListAppender listAppender = (ListAppender) siftingAppender.getAppenderTracker().find(key); - assertEquals(expectedCount, listAppender.list.size()); - } - - void invokeServer(String uri) throws Exception { - URL url = new URL("http://localhost:" + RANDOM_SERVER_PORT + uri); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoInput(true); - Util.readToString(connection.getInputStream()); - Thread.sleep(10); - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventSerializationTest.java b/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventSerializationTest.java deleted file mode 100644 index 93dbbfa0d7..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventSerializationTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.spi; - -import ch.qos.logback.access.dummy.DummyAccessEventBuilder; -import ch.qos.logback.access.dummy.DummyRequest; -import ch.qos.logback.access.dummy.DummyResponse; -import ch.qos.logback.access.dummy.DummyServerAdapter; -import ch.qos.logback.access.net.HardenedAccessEventInputStream; -import org.junit.jupiter.api.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -public class AccessEventSerializationTest { - - private Object buildSerializedAccessEvent() throws IOException, ClassNotFoundException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - IAccessEvent ae = DummyAccessEventBuilder.buildNewAccessEvent(); - // average time for the next method: 5000 nanos - ae.prepareForDeferredProcessing(); - oos.writeObject(ae); - oos.flush(); - - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - HardenedAccessEventInputStream hardenedOIS = new HardenedAccessEventInputStream(bais); - - Object sae = hardenedOIS.readObject(); - hardenedOIS.close(); - return sae; - } - - @Test - public void testSerialization() throws IOException, ClassNotFoundException { - Object o = buildSerializedAccessEvent(); - assertNotNull(o); - IAccessEvent aeBack = (IAccessEvent) o; - - assertEquals(DummyResponse.DUMMY_DEFAULT_HDEADER_MAP, aeBack.getResponseHeaderMap()); - assertEquals(DummyResponse.DUMMY_DEFAULT_HDEADER_MAP.get("x"), aeBack.getResponseHeader("x")); - assertEquals(DummyResponse.DUMMY_DEFAULT_HDEADER_MAP.get("headerName1"), - aeBack.getResponseHeader("headerName1")); - assertEquals(DummyResponse.DUMMY_DEFAULT_HDEADER_MAP.size(), aeBack.getResponseHeaderNameList().size()); - assertEquals(DummyResponse.DUMMY_DEFAULT_CONTENT_COUNT, aeBack.getContentLength()); - assertEquals(DummyResponse.DUMMY_DEFAULT_STATUS, aeBack.getStatusCode()); - - assertEquals(DummyRequest.DUMMY_CONTENT_STRING, aeBack.getRequestContent()); - - assertEquals(DummyRequest.DUMMY_RESPONSE_CONTENT_STRING, aeBack.getResponseContent()); - - assertEquals(DummyRequest.DUMMY_DEFAULT_ATTR_MAP.get("testKey"), aeBack.getAttribute("testKey")); - } - - // Web containers may (and will) recycle requests objects. So we must make sure - // that after - // we prepared an event for deferred processing it won't be using data from the - // original - // HttpRequest object which may at that time represent another request - @Test - public void testAttributesAreNotTakenFromRecycledRequestWhenProcessingDeferred() { - - DummyRequest request = new DummyRequest(); - DummyResponse response = new DummyResponse(); - DummyServerAdapter adapter = new DummyServerAdapter(request, response); - AccessContext accessContext = new AccessContext(); - - IAccessEvent event = new AccessEvent(accessContext, request, response, adapter); - - request.setAttribute("testKey", "ORIGINAL"); - - event.prepareForDeferredProcessing(); - - request.setAttribute("testKey", "NEW"); - - // Event should capture the original value - assertEquals("ORIGINAL", event.getAttribute("testKey")); - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventTest.java b/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventTest.java deleted file mode 100755 index 9e66b89475..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package ch.qos.logback.access.spi; - -import ch.qos.logback.access.dummy.DummyAccessEventBuilder; -import ch.qos.logback.access.dummy.DummyRequest; -import ch.qos.logback.core.testUtil.RandomUtil; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class AccessEventTest { - - int diff = RandomUtil.getPositiveInt(); - - @BeforeEach - public void setUp() throws Exception { - } - - @AfterEach - public void tearDown() throws Exception { - } - - // See LOGBACK-1189 - @Test - public void callingPrepareForDeferredProcessingShouldBeIdempotent() { - String key = "key-" + diff; - String val = "val-" + diff; - - IAccessEvent ae = DummyAccessEventBuilder.buildNewAccessEvent(); - DummyRequest request = (DummyRequest) ae.getRequest(); - Map headersMap = request.getHeaders(); - Map parametersMap = request.getParameterMap(); - - headersMap.put(key, val); - request.setAttribute(key, val); - parametersMap.put(key, new String[] { val }); - ae.prepareForDeferredProcessing(); - assertEquals(val, ae.getAttribute(key)); - assertEquals(val, ae.getRequestHeader(key)); - assertEquals(val, ae.getRequestParameter(key)[0]); - - request.setAttribute(key, "change"); - headersMap.put(key, "change"); - parametersMap.put(key, new String[] { "change" }); - ae.prepareForDeferredProcessing(); - assertEquals(val, ae.getAttribute(key)); - assertEquals(val, ae.getRequestHeader(key)); - assertEquals(val, ae.getRequestParameter(key)[0]); - - } - -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/testUtil/NotifyingListAppender.java b/logback-access/src/test/java/ch/qos/logback/access/testUtil/NotifyingListAppender.java deleted file mode 100644 index 5061c9fc41..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/testUtil/NotifyingListAppender.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.testUtil; - -import java.util.concurrent.LinkedBlockingQueue; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.AppenderBase; - -public class NotifyingListAppender extends AppenderBase { - - public final LinkedBlockingQueue list = new LinkedBlockingQueue(); - - protected void append(IAccessEvent e) { - list.add(e); - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/tomcat/LogbackValveTest.java b/logback-access/src/test/java/ch/qos/logback/access/tomcat/LogbackValveTest.java deleted file mode 100755 index 84cdad1f96..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/tomcat/LogbackValveTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.tomcat; - -import ch.qos.logback.access.AccessTestConstants; -import ch.qos.logback.core.status.Status; -import ch.qos.logback.core.status.testUtil.StatusChecker; -import org.apache.catalina.LifecycleException; -import org.apache.catalina.core.ContainerBase; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -public class LogbackValveTest { - - LogbackValve valve = new LogbackValve(); - StatusChecker checker = new StatusChecker(valve); - - @AfterEach - public void tearDown() { - System.clearProperty(LogbackValve.CATALINA_BASE_KEY); - System.clearProperty(LogbackValve.CATALINA_HOME_KEY); - } - - @Test - public void nonExistingConfigFileShouldResultInWarning() throws LifecycleException { - final String resourceName = "logback-test2-config.xml"; - setupValve(resourceName); - valve.start(); - checker.assertContainsMatch(Status.WARN, "Failed to find valid"); - } - - @Test - public void fileUnderCatalinaBaseShouldBeFound() throws LifecycleException { - System.setProperty(LogbackValve.CATALINA_BASE_KEY, AccessTestConstants.JORAN_INPUT_PREFIX + "tomcat/"); - final String fileName = "logback-access.xml"; - setupValve(fileName); - valve.start(); - checker.assertContainsMatch("Found configuration file"); - checker.assertContainsMatch("Done configuring"); - checker.assertIsErrorFree(); - } - - @Test - public void nonExistingConfigFileUnderCatalinaBaseShouldResultInWarning() throws LifecycleException { - final String path = AccessTestConstants.JORAN_INPUT_PREFIX + "tomcat/"; - final String fileName = "logback-test2-config.xml"; - final String fullPath = path + fileName; - System.setProperty(LogbackValve.CATALINA_BASE_KEY, path); - setupValve(fileName); - valve.start(); - checker.assertContainsMatch("Could NOT find configuration file"); - checker.assertIsErrorFree(); - } - - @Test - public void fileUnderCatalinaHomeShouldBeFound() throws LifecycleException { - System.setProperty(LogbackValve.CATALINA_HOME_KEY, AccessTestConstants.JORAN_INPUT_PREFIX + "tomcat/"); - final String fileName = "logback-access.xml"; - setupValve(fileName); - valve.start(); - checker.assertContainsMatch("Found configuration file"); - checker.assertContainsMatch("Done configuring"); - checker.assertIsErrorFree(); - } - - @Test - public void resourceShouldBeFound() throws LifecycleException { - final String fileName = "logback-asResource.xml"; - setupValve(fileName); - valve.start(); - checker.assertContainsMatch("Found ." + fileName + ". as a resource."); - checker.assertContainsMatch("Done configuring"); - checker.assertIsErrorFree(); - } - - @Test - public void executorServiceShouldBeNotNull() throws LifecycleException { - final String fileName = "logback-asResource.xml"; - setupValve(fileName); - valve.start(); - assertNotNull(valve.getScheduledExecutorService()); - - } - - private void setupValve(final String resourceName) { - valve.setFilename(resourceName); - valve.setName("test"); - valve.setContainer(new ContainerBase() { - @Override - protected String getObjectNameKeyProperties() { - return "getObjectNameKeyProperties-test"; - } - }); - } -} \ No newline at end of file diff --git a/logback-access/src/test/resources/logback-asResource.xml b/logback-access/src/test/resources/logback-asResource.xml deleted file mode 100755 index b4d2a9f8ee..0000000000 --- a/logback-access/src/test/resources/logback-asResource.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - %h %l %u %user %date "%r" %s %b - - - - - \ No newline at end of file