pax_global_header00006660000000000000000000000064152375572150014526gustar00rootroot0000000000000052 comment=a0dc617e6e3dc82128be5d37233b0d533f6176ec logback-access-v_2.0.15/000077500000000000000000000000001523755721500150015ustar00rootroot00000000000000logback-access-v_2.0.15/.gitignore000066400000000000000000000002531523755721500167710ustar00rootroot00000000000000target .classpath .factorypath .project .settings .idea *~ *.iml *.ipr *.iws # Compiled class file *.class # Log file *.log # ignore files with pound characters \#*\#logback-access-v_2.0.15/LICENSE.txt000066400000000000000000000007271523755721500166320ustar00rootroot00000000000000Logback LICENSE --------------- Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2026, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v2.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. logback-access-v_2.0.15/README.md000066400000000000000000000007371523755721500162670ustar00rootroot00000000000000 What is logback-access? The logback-access module integrates with Servlet containers such as Jetty or Tomcat to provide rich and powerful HTTP-access log functionality. Previously, part of the logback distribution, since March 2024 it resides in its own repository at https://github.com/qos-ch/logback-access Version 2.0.0 of logback-access supports Tomcat versions 10 and 11, and Jetty versions 11 and 12. For further documentation see https://logback.qos.ch/access.html. logback-access-v_2.0.15/SECURITY.md000066400000000000000000000026011523755721500165710ustar00rootroot00000000000000 ## Reporting security issues Please report security issues related to the logback-access project to the following email address: support(at)qos.ch ## Verifying contents All logback-access project artifacts published on Maven central are signed. For each artifact, there is an associated signature file with the .asc suffix. The cryptographic key was updated 2022-08-08 to use a more modern Elliptic curve algorithm instead of RSA previously. ### After 2022-08-08 To verify the signature use [this public key](https://www.slf4j.org/public-keys/60200AC4AE761F1614D6C46766D68DAA073BE985.gpg). Here is its fingerprint: ``` pub nistp521 2022-08-08 [SC] 60200AC4AE761F1614D6C46766D68DAA073BE985 uid Ceki Gulcu sub nistp521 2022-08-08 [E] ``` A copy of this key is stored on the [keys.openpgp.org](https://keys.openpgp.org) keyserver. To add it to your public key ring use the following command: ``` > FINGER_PRINT=60200AC4AE761F1614D6C46766D68DAA073BE985 > gpg --keyserver hkps://keys.openpgp.org --recv-keys $FINGER_PRINT ``` ## Preventing commit history overwrite In order to prevent loss of commit history, developers of the project are highly encouraged to deny branch deletions or history overwrites by invoking the following two commands on their local copy of the repository. ``` git config receive.denyDelete true git config receive.denyNonFastForwards true ```logback-access-v_2.0.15/javaConventions.xml000066400000000000000000001261451523755721500207030ustar00rootroot00000000000000 logback-access-v_2.0.15/logback-access-common-blackbox/000077500000000000000000000000001523755721500227135ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/pom.xml000066400000000000000000000111741523755721500242340ustar00rootroot00000000000000 4.0.0 ch.qos.logback.access parent 2.0.15 logback-access-common-blackbox jar Logback Access Common Blackbox Module Logback Access Common Blackbox module org.junit.jupiter junit-jupiter-params ${junit-jupiter-params.version} test ch.qos.logback.access logback-access-common compile org.apache.maven.plugins maven-jar-plugin org.apache.maven.plugins maven-surefire-plugin once --add-opens java.base/java.io=ch.qos.logback.access.common.blackbox plain true ch.qos.logback.access.common.blackbox.util.WithOlderCoreAccessCommonVersionUtilTest older-core 1.5.26 ch.qos.logback logback-core ${older-logback-core.version} org.apache.maven.plugins maven-surefire-plugin default-test ${older-logback-core.version} once plain true ch.qos.logback.access.common.blackbox.util.WithOlderCoreAccessCommonVersionUtilTest **/*Xest.java logback-access-v_2.0.15/logback-access-common-blackbox/src/000077500000000000000000000000001523755721500235025ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/000077500000000000000000000000001523755721500244615ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/000077500000000000000000000000001523755721500256205ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/integration/000077500000000000000000000000001523755721500301435ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/integration/db/000077500000000000000000000000001523755721500305305ustar00rootroot00000000000000mysql-with-driver.xml000066400000000000000000000006661523755721500346120ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/integration/db com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/logback root oracle10g-with-driver.xml000066400000000000000000000006711523755721500352160ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/integration/db oracle.jdbc.OracleDriver jdbc:oracle:thin:@localhost:1522:xe hr hr oracle11g-with-driver.xml000066400000000000000000000007021523755721500352120ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/integration/db oracle.jdbc.OracleDriver jdbc:oracle:thin:@localhost:1521:orcl SCOTT SCOTT postgresql-with-driver.xml000066400000000000000000000007261523755721500356450ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/integration/db org.postgresql.Driver jdbc:postgresql://192.168.1.5:5432/test logback logback sqlserver-with-driver.xml000066400000000000000000000007521523755721500354670ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/integration/db com.microsoft.sqlserver.jdbc.SQLServerDriver jdbc:sqlserver://localhost:1987;databaseName=logback; logback logback logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/000077500000000000000000000000001523755721500267315ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/collision/000077500000000000000000000000001523755721500307245ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/collision/repeatFile.xml000066400000000000000000000012261523755721500335270ustar00rootroot00000000000000 ${outputTargetKey} %protocol %n ${outputTargetKey} %protocol %n repeatMixedFileAndRolling.xml000066400000000000000000000020261523755721500364100ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/collision ${outputTargetKey} ${fileNamePatternKey} 30 3GB %protocol %n ${outputTargetKey} %protocol %n repeatRollingFileAppenderByFile.xml000066400000000000000000000024121523755721500375470ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/collision ${outputTargetKey} ${fileNamePatternKey} 30 3GB %protocol %n ${outputTargetKey} DIST${fileNamePatternKey} 30 3GB %protocol %n repeatRollingFileAppenderByFilePattern.xml000066400000000000000000000024121523755721500411050ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/collision ${outputTargetKey} ${fileNamePatternKey} 30 3GB %protocol %n DIST${outputTargetKey} ${fileNamePatternKey} 30 3GB %protocol %n logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/conditional/000077500000000000000000000000001523755721500312345ustar00rootroot00000000000000conditionalConsole.xml000066400000000000000000000005361523755721500355310ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/conditional %h %l %u %user %date "%r" %s %b conditionalConsole_ELSE.xml000066400000000000000000000007371523755721500363440ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/conditional %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/defaultLayout.xml000066400000000000000000000010051523755721500322710ustar00rootroot00000000000000 %requestMethod logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/evaluator/000077500000000000000000000000001523755721500307335ustar00rootroot00000000000000combinedStatusCodeRequestURI.xml000066400000000000000000000021021523755721500371010ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/evaluator 404 NEUTRAL DENY \.css$ DENY NEUTRAL noClassEventEvaluator.xml000066400000000000000000000011301523755721500356600ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/evaluator return true; DENY requestURIEvaluator.xml000066400000000000000000000014631523755721500353350ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/evaluator \.css$ DENY NEUTRAL statusCodeEventEvaluator.xml000066400000000000000000000013521523755721500364020ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/evaluator 404 NEUTRAL DENY logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/smoke.xml000066400000000000000000000002101523755721500305620ustar00rootroot00000000000000 logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/tomcat/000077500000000000000000000000001523755721500302205ustar00rootroot00000000000000logback-access.xml000066400000000000000000000005231523755721500335240ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/input/joran/tomcat %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/000077500000000000000000000000001523755721500254025ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/000077500000000000000000000000001523755721500257745ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/000077500000000000000000000000001523755721500265765ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/000077500000000000000000000000001523755721500302005ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/000077500000000000000000000000001523755721500314415ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/000077500000000000000000000000001523755721500327315ustar00rootroot00000000000000blackbox/000077500000000000000000000000001523755721500344375ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/commonCommonBlackboxConstants.java000066400000000000000000000015111523755721500420730ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox; public class CommonBlackboxConstants { 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/"; public static final String OUTPUT_DIR_PREFIX = "target/test-output/"; } dummy/000077500000000000000000000000001523755721500355725ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackboxDummyAccessEventBuilder.java000066400000000000000000000037501523755721500431700ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/dummy/** * 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.common.blackbox.dummy; import ch.qos.logback.access.common.spi.AccessContext; import ch.qos.logback.access.common.spi.AccessEvent; public class DummyAccessEventBuilder { DummyRequest request; DummyResponse response; DummyServerAdapter adapter; AccessContext accessContext; public DummyAccessEventBuilder() { } public DummyAccessEventBuilder setRequest(DummyRequest request) { this.request = request; return this; } public DummyAccessEventBuilder setResponse(DummyResponse response) { this.response = response; return this; } public DummyAccessEventBuilder setAdapter(DummyServerAdapter adapter) { this.adapter = adapter; return this; } public DummyAccessEventBuilder setAccessContext(AccessContext accessContext) { this.accessContext = accessContext; return this; } public AccessEvent build() { if (this.request == null) this.request = new DummyRequest(); if (this.response == null) response = new DummyResponse(); if (this.adapter == null) adapter = new DummyServerAdapter(request, response); if (this.accessContext == null) accessContext = new AccessContext(); return new AccessEvent(accessContext, request, response, adapter); } static public AccessEvent buildNewDefaultAccessEvent() { DummyAccessEventBuilder daeb = new DummyAccessEventBuilder(); return daeb.build(); } } DummyRequest.java000066400000000000000000000224621523755721500411070ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/dummy/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.dummy; import ch.qos.logback.access.common.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; Cookie[] cookiesArray; 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); Cookie cookie = new Cookie("testName", "testCookie"); cookiesArray = new Cookie[] { cookie }; } public String getAuthType() { return null; } public String getContextPath() { return null; } public Cookie[] getCookies() { return cookiesArray; } public void setCookies(Cookie[] cookiesArray) { this.cookiesArray = cookiesArray; } 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. } @Override public String getRequestId() { return null; } @Override public String getProtocolRequestId() { return null; } @Override public ServletConnection getServletConnection() { return null; } 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; } } DummyResponse.java000066400000000000000000000102641523755721500412520ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/dummy/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.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 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 } } DummyServerAdapter.java000066400000000000000000000023071523755721500422220ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/dummy/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.dummy; import ch.qos.logback.access.common.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; } } DummyServletOutputStream.java000066400000000000000000000026711523755721500435000ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/dummy/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.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 } } joran/000077500000000000000000000000001523755721500355505ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackboxFileCollisionAnalyserTest.java000066400000000000000000000110161523755721500435040ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/joran/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.joran; import ch.qos.logback.access.common.blackbox.CommonBlackboxConstants; import ch.qos.logback.access.common.blackbox.testUtil.MiniStatusChecker; import ch.qos.logback.access.common.joran.JoranConfigurator; import ch.qos.logback.access.common.spi.AccessContext; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.Appender; import ch.qos.logback.core.FileAppender; import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.rolling.RollingFileAppender; import ch.qos.logback.core.status.Status; import ch.qos.logback.core.testUtil.RandomUtil; import ch.qos.logback.core.util.StatusPrinter2; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static ch.qos.logback.core.model.processor.FileCollisionAnalyser.COLLISION_MESSAGE; import static org.junit.jupiter.api.Assertions.*; public class FileCollisionAnalyserTest { AccessContext accessContext = new AccessContext(); MiniStatusChecker miniStatusChecker = new MiniStatusChecker(accessContext); int diff = RandomUtil.getPositiveInt(); String outputTargetVal = CommonBlackboxConstants.OUTPUT_DIR_PREFIX + "collision/output-" + diff + ".log"; String fileNamePatternVal = CommonBlackboxConstants.OUTPUT_DIR_PREFIX + "collision/output-%d{yyyy-MM-dd}-" + diff + ".log"; StatusPrinter2 statusPrinter2 = new StatusPrinter2(); @BeforeEach public void setUp() { } void configure(String file) throws JoranException { accessContext.putProperty("outputTargetKey", outputTargetVal); accessContext.putProperty("fileNamePatternKey", fileNamePatternVal); JoranConfigurator jc = new JoranConfigurator(); jc.setContext(accessContext); jc.doConfigure(file); } @Test void testFileCollision() throws JoranException { String configFile = CommonBlackboxConstants.JORAN_INPUT_PREFIX + "collision/repeatFile.xml"; runCollisionTest(configFile, 1, 0, "file", outputTargetVal); } @Test void testRollingFileAppenderCollisionByFile() throws JoranException { String configFile = CommonBlackboxConstants.JORAN_INPUT_PREFIX + "collision/repeatRollingFileAppenderByFile.xml"; runCollisionTest(configFile, 0, 1, "file", outputTargetVal); } @Test void testRollingFileAppenderCollisionByFilePattern() throws JoranException { String configFile = CommonBlackboxConstants.JORAN_INPUT_PREFIX + "collision/repeatRollingFileAppenderByFilePattern.xml"; runCollisionTest(configFile, 0, 1, "fileNamePattern", fileNamePatternVal); } @Test public void testMixedFileaAppenderRollingFileAppenderCollisionByFile() throws JoranException { String configFile = CommonBlackboxConstants.JORAN_INPUT_PREFIX + "collision/repeatMixedFileAndRolling.xml"; runCollisionTest(configFile, 0, 1, "file", outputTargetVal); } public void runCollisionTest(String configFile, int fileAppenderCount, int rollingAppenderCount, String tagName, String value) throws JoranException { configure(configFile); //statusPrinter2.print(accessContext); Appender fileAppender1 = accessContext.getAppender("FILE1"); assertNotNull(fileAppender1); Appender fileAppender2 = accessContext.getAppender("FILE2"); assertNull(fileAppender2); String expectationPattern = COLLISION_MESSAGE.replace("[", "\\[").replace("]", "\\]"); String sanitizeValue = value.replace("{", "\\{").replace("}", "\\}"); String expected = String.format(expectationPattern, "FILE2", tagName, sanitizeValue, "FILE1"); //System.out.println(expected); assertTrue(miniStatusChecker.containsMatch(Status.ERROR, expected)); assertEquals(fileAppenderCount, miniStatusChecker.matchCount("About to instantiate appender of type \\[" + FileAppender.class.getName() + "\\]")); assertEquals(rollingAppenderCount, miniStatusChecker.matchCount("About to instantiate appender of type \\[" + RollingFileAppender.class.getName() + "\\]")); } } JoranConfiguratorTest.java000066400000000000000000000152721523755721500427160ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/joran/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.joran; import ch.qos.logback.access.common.blackbox.CommonBlackboxConstants; import ch.qos.logback.access.common.blackbox.dummy.DummyAccessEventBuilder; import ch.qos.logback.access.common.blackbox.dummy.DummyRequest; import ch.qos.logback.access.common.blackbox.dummy.DummyResponse; import ch.qos.logback.access.common.blackbox.testUtil.MiniStatusChecker; import ch.qos.logback.access.common.boolex.StubEventEvaluator; import ch.qos.logback.access.common.joran.JoranConfigurator; import ch.qos.logback.access.common.spi.AccessContext; import ch.qos.logback.access.common.spi.AccessEvent; import ch.qos.logback.access.common.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(); MiniStatusChecker miniStatusChecker = new MiniStatusChecker(context); @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(CommonBlackboxConstants.TEST_DIR_PREFIX + "input/joran/smoke.xml"); StatusPrinter.print(context); ListAppender listAppender = (ListAppender) context.getAppender("LIST"); assertNotNull(listAppender); IAccessEvent event = DummyAccessEventBuilder.buildNewDefaultAccessEvent(); 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(CommonBlackboxConstants.TEST_DIR_PREFIX + "input/joran/defaultLayout.xml"); StringListAppender listAppender = (StringListAppender) context .getAppender("STR_LIST"); IAccessEvent event = DummyAccessEventBuilder.buildNewDefaultAccessEvent(); listAppender.doAppend(event); assertEquals(1, listAppender.strList.size()); // the result contains a line separator at the end assertTrue(listAppender.strList.get(0).startsWith("testMethod")); } @Test public void noClassEventEvaluator() throws Exception { configure(CommonBlackboxConstants.TEST_DIR_PREFIX + "input/joran/evaluator/noClassEventEvaluator.xml"); ListAppender listAppender = (ListAppender) context.getAppender("LIST"); IAccessEvent event = DummyAccessEventBuilder.buildNewDefaultAccessEvent(); listAppender.doAppend(event); assertEquals(1, listAppender.list.size()); assertEquals(1, listAppender.list.size()); IAccessEvent ae = listAppender.list.get(0); assertNotNull(ae); assertTrue(miniStatusChecker.containsMatch(StubEventEvaluator.MSG_0)); assertTrue(miniStatusChecker.containsMatch(StubEventEvaluator.MSG_1)); } @Test public void statusCodeEventEvaluator() throws Exception { configure(CommonBlackboxConstants.TEST_DIR_PREFIX + "input/joran/evaluator/statusCodeEventEvaluator.xml"); ListAppender listAppender = (ListAppender) context.getAppender("LIST"); AccessEvent event0 = createAccessEventWithRequestURIAndStatusCode( "msg1", 404); AccessEvent event1 = createAccessEventWithRequestURIAndStatusCode("msg2", 200); listAppender.doAppend(event0); listAppender.doAppend(event1); assertEquals(1, listAppender.list.size()); } @Test public void requestURIEventEvaluatorTest() throws Exception { configure(CommonBlackboxConstants.TEST_DIR_PREFIX + "input/joran/evaluator/requestURIEvaluator.xml"); ListAppender listAppender = (ListAppender) context.getAppender("LIST"); AccessEvent event0 = createAccessEventWithRequestURIAndStatusCode( "index.html", 200); AccessEvent event1 = createAccessEventWithRequestURIAndStatusCode( "toto.css", 200); listAppender.doAppend(event0); listAppender.doAppend(event1); assertEquals(1, listAppender.list.size()); IAccessEvent eventInList0 = listAppender.list.get(0); assertTrue(eventInList0.getRequestURI().contains("index.html")); } @Test public void combinedStatusCode_RequestURIEventEvaluatorsTest() throws Exception { configure(CommonBlackboxConstants.TEST_DIR_PREFIX + "input/joran/evaluator/combinedStatusCodeRequestURI.xml"); ListAppender listAppender = (ListAppender) context.getAppender("LIST"); AccessEvent event0 = createAccessEventWithRequestURIAndStatusCode( "index.html", 404); AccessEvent event1 = createAccessEventWithRequestURIAndStatusCode( "toto.css", 404); listAppender.doAppend(event0); listAppender.doAppend(event1); assertEquals(1, listAppender.list.size()); IAccessEvent eventInList0 = listAppender.list.get(0); assertTrue(eventInList0.getRequestURI().contains("index.html")); } private static AccessEvent createAccessEventWithRequestURIAndStatusCode(String requestURI, int statusCode) { DummyAccessEventBuilder daeb = new DummyAccessEventBuilder(); DummyRequest dummyRequest = new DummyRequest(); dummyRequest.setRequestUri(requestURI); daeb.setRequest(dummyRequest); DummyResponse dummyResponse = new DummyResponse(); dummyResponse.setStatus(statusCode); daeb.setResponse(dummyResponse); AccessEvent event0 = daeb.build(); return event0; } } net/000077500000000000000000000000001523755721500352255ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackboxNOPOutputStream.java000066400000000000000000000013331523755721500411210ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/net/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.net; import java.io.IOException; import java.io.OutputStream; public class NOPOutputStream extends OutputStream { @Override public void write(int b) throws IOException { // do nothing } } SerializationPerfTest.java000066400000000000000000000067761523755721500424020ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/net/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.net; import java.io.IOException; import java.io.ObjectOutputStream; import ch.qos.logback.access.common.blackbox.dummy.DummyAccessEventBuilder; import ch.qos.logback.access.common.spi.IAccessEvent; 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.buildNewDefaultAccessEvent(); // 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.buildNewDefaultAccessEvent(); 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 } } URLEvaluatorTest.java000066400000000000000000000056461523755721500412700ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/net/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.net; import ch.qos.logback.access.common.blackbox.dummy.DummyRequest; import ch.qos.logback.access.common.blackbox.dummy.DummyResponse; import ch.qos.logback.access.common.blackbox.dummy.DummyServerAdapter; import ch.qos.logback.access.common.net.URLEvaluator; import ch.qos.logback.access.common.spi.AccessContext; import ch.qos.logback.access.common.spi.AccessEvent; import ch.qos.logback.access.common.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 ch.qos.logback.access.common.net.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)); } } pattern/000077500000000000000000000000001523755721500361145ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackboxConverterTest.java000066400000000000000000000223201523755721500415650ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.pattern; import ch.qos.logback.access.common.blackbox.dummy.DummyRequest; import ch.qos.logback.access.common.blackbox.dummy.DummyResponse; import ch.qos.logback.access.common.blackbox.dummy.DummyServerAdapter; import ch.qos.logback.access.common.pattern.ContentLengthConverter; import ch.qos.logback.access.common.pattern.DateConverter; import ch.qos.logback.access.common.pattern.LocalPortConverter; import ch.qos.logback.access.common.pattern.RemoteHostConverter; import ch.qos.logback.access.common.pattern.RemoteUserConverter; import ch.qos.logback.access.common.pattern.RequestAttributeConverter; import ch.qos.logback.access.common.pattern.RequestCookieConverter; import ch.qos.logback.access.common.pattern.RequestHeaderConverter; import ch.qos.logback.access.common.pattern.RequestMethodConverter; import ch.qos.logback.access.common.pattern.RequestProtocolConverter; import ch.qos.logback.access.common.pattern.RequestURIConverter; import ch.qos.logback.access.common.pattern.RequestURLConverter; import ch.qos.logback.access.common.pattern.ResponseHeaderConverter; import ch.qos.logback.access.common.pattern.ServerNameConverter; import ch.qos.logback.access.common.pattern.StatusCodeConverter; import ch.qos.logback.access.common.spi.AccessContext; import ch.qos.logback.access.common.spi.AccessEvent; import ch.qos.logback.core.CoreConstants; 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; import static org.junit.jupiter.api.Assertions.assertTrue; 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() { dateConverterChecker(parseDateAsMillis("2024-08-14T15:29:25.956Z"), List.of(), "14/.../2024:17:29:25 \\+\\d*"); dateConverterChecker(parseDateAsMillis("2022-10-21T10:30:20.800Z"), List.of(CoreConstants.CLF_DATE_PATTERN, "Australia/Sydney", "en-AU"), "21/Oct/2022:21:30:20 \\+1100"); dateConverterChecker(parseDateAsMillis("2022-09-21T10:30:20.800Z"), List.of(CoreConstants.CLF_DATE_PATTERN, "UTC", "en"), "21/Sep/2022:10:30:20 \\+0000"); dateConverterChecker(parseDateAsMillis("2022-09-21T10:30:20.800Z"), List.of(CoreConstants.CLF_DATE_PATTERN, "UTC", "en-GB"), "21/Sept/2022:10:30:20 \\+0000"); } private long parseDateAsMillis(String aDate) { Instant instant = Instant.parse(aDate); return instant.toEpochMilli(); } void dateConverterChecker(long millis, List options, String regex) { event.setTimeStamp(millis); DateConverter dateConverter = new DateConverter(); dateConverter.setContext(accessContext); dateConverter.setOptionList(options); dateConverter.start(); assertTrue(dateConverter.isStarted()); Instant now = Instant.ofEpochMilli(millis); String result = dateConverter.convert(event); System.out.println("restult=" + result + " regex=" + regex); assertTrue(result.matches(regex)); } 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() { ch.qos.logback.access.common.pattern.RemoteIPAddressConverter converter = new ch.qos.logback.access.common.pattern.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(); request.setRequestUri("/toto"); 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); } } servlet/000077500000000000000000000000001523755721500361235ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackboxTeeFilterTest.java000066400000000000000000000047241523755721500415200ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/servlet/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.servlet; import ch.qos.logback.access.common.servlet.TeeFilter; import org.junit.jupiter.api.Assertions; 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() { Assertions.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")); } } TeeHttpServletResponseTest.java000066400000000000000000000045251523755721500442750ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/servlet/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.servlet; import ch.qos.logback.access.common.blackbox.dummy.DummyResponse; import ch.qos.logback.access.common.blackbox.dummy.DummyServletOutputStream; import ch.qos.logback.access.common.servlet.TeeHttpServletResponse; 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()); } } spi/000077500000000000000000000000001523755721500352325ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackboxAccessEventSerializationTest.java000066400000000000000000000102161523755721500436760ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/spi/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.spi; import ch.qos.logback.access.common.blackbox.dummy.DummyAccessEventBuilder; import ch.qos.logback.access.common.blackbox.dummy.DummyRequest; import ch.qos.logback.access.common.blackbox.dummy.DummyResponse; import ch.qos.logback.access.common.blackbox.dummy.DummyServerAdapter; import ch.qos.logback.access.common.net.HardenedAccessEventInputStream; import ch.qos.logback.access.common.spi.AccessContext; import ch.qos.logback.access.common.spi.AccessEvent; import ch.qos.logback.access.common.spi.IAccessEvent; 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.buildNewDefaultAccessEvent(); // 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(null, 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")); } } AccessEventTest.java000066400000000000000000000063021523755721500411410ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/spi/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.spi; import ch.qos.logback.access.common.blackbox.dummy.DummyAccessEventBuilder; import ch.qos.logback.access.common.blackbox.dummy.DummyRequest; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.testUtil.RandomUtil; import jakarta.servlet.http.Cookie; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; 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.buildNewDefaultAccessEvent(); 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]); } @Test void cookiesListTest() throws Exception { IAccessEvent ae = DummyAccessEventBuilder.buildNewDefaultAccessEvent(); List cookiesList = ae.getCookies(); assertEquals(1, cookiesList.size()); Cookie cookie = new Cookie("testName", "testCookie"); assertEquals(cookie, cookiesList.get(0)); } @Test void cookiesEmptyListTest() throws Exception { DummyAccessEventBuilder dummyAccessEventBuilder = new DummyAccessEventBuilder(); DummyRequest dummyRequest = new DummyRequest(); dummyRequest.setCookies(null); dummyAccessEventBuilder.setRequest(dummyRequest); IAccessEvent ae = dummyAccessEventBuilder.build(); List cookiesList = ae.getCookies(); assertTrue(cookiesList.isEmpty()); } } testUtil/000077500000000000000000000000001523755721500362545ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackboxMiniStatusChecker.java000066400000000000000000000023241523755721500425050ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/testUtil/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.testUtil; import ch.qos.logback.core.Context; import ch.qos.logback.core.status.Status; import ch.qos.logback.core.status.StatusManager; import ch.qos.logback.core.status.StatusUtil; import org.junit.jupiter.api.Assertions; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; public class MiniStatusChecker extends StatusUtil { public static final int UNKNOWN_LEVEL = -1; public MiniStatusChecker(StatusManager sm) { super(sm); } public MiniStatusChecker(Context context) { super(context); } public void assertIsWarningOrErrorFree() { Assertions.assertTrue(isWarningOrErrorFree(0)); } } util/000077500000000000000000000000001523755721500354145ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackboxAccessCommonVersionUtilTest.java000066400000000000000000000051771523755721500437070ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/util/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.util; import ch.qos.logback.access.common.AccessConstants; import ch.qos.logback.access.common.blackbox.testUtil.MiniStatusChecker; import ch.qos.logback.access.common.util.AccessCommonVersionUtil; import ch.qos.logback.core.Context; import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.util.CoreVersionUtil; import ch.qos.logback.core.util.StatusPrinter2; import org.junit.jupiter.api.Test; import static ch.qos.logback.access.common.AccessConstants.LOGBACK_ACCESS_COMMON_MODULE_NAME; import static ch.qos.logback.access.common.AccessConstants.LOGBACK_CORE_MODULE_NAME; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class AccessCommonVersionUtilTest { Context context = new ContextBase(); MiniStatusChecker statusChecker = new MiniStatusChecker(context); StatusPrinter2 statusPrinter2 = new StatusPrinter2(); @Test void testAccessCommonVersionBySelfDeclaredProperties() { String version = AccessCommonVersionUtil.getAccessCommonVersionBySelfDeclaredProperties(); assertNotNull(version); assertTrue(version.startsWith("2.0")); } @Test void testExpectedAndFoundVersionOfCore() { String coreVersion = CoreVersionUtil.getCoreVersionBySelfDeclaredProperties(); String accessCommonVersion = AccessCommonVersionUtil.getAccessCommonVersionBySelfDeclaredProperties(); AccessCommonVersionUtil accessCommonVersionUtil = new AccessCommonVersionUtil(context); accessCommonVersionUtil.compareExpectedAndFoundVersion(coreVersion, AccessConstants.class, accessCommonVersion, LOGBACK_ACCESS_COMMON_MODULE_NAME, LOGBACK_CORE_MODULE_NAME); //String logbackCoreVersion = AccessCommonVersionUtil.getExpectedVersionOfDependencyByProperties(AccessConstants.class, "logback-access-common-dependencies.properties", "logback-core"); //System.out.println("logback-core version expected by logback-access-common is " + logbackCoreVersion); //assertNotNull(logbackCoreVersion); statusPrinter2.print(context); statusChecker.assertIsWarningOrErrorFree(); } } WithOlderCoreAccessCommonVersionUtilTest.java000066400000000000000000000044011523755721500463270ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/ch/qos/logback/access/common/blackbox/util/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.blackbox.util; import ch.qos.logback.access.common.AccessConstants; import ch.qos.logback.access.common.util.AccessCommonVersionUtil; import ch.qos.logback.core.Context; import ch.qos.logback.core.ContextBase; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; /** * * *

Use the following command to run this test *

* *
  mvn install;  # avoid future compilation errors
 *   cd logback-access-common-blackbox;
 *   mvn test -P older-core -Dtest=ch.qos.logback.access.common.blackbox.util.WithOlderCoreAccessCommonVersionUtilTest
 *   
*/ public class WithOlderCoreAccessCommonVersionUtilTest { Context context = new ContextBase(); @Test public void otherVersionTest() { String olderCoreVersion = System.getProperty("olderCore", "none"); System.out.println("olderCoreVersion="+olderCoreVersion); assertTrue(olderCoreVersion.startsWith("1.5.")); try { AccessCommonVersionUtil accessCommonVersionUtil = new AccessCommonVersionUtil(context); accessCommonVersionUtil.getExpectedVersionOfDependencyByProperties(AccessConstants.class, "", ""); fail("Expected Error"); } catch (NoClassDefFoundError e) { // logback-core version is 1.5.24 or older System.out.println("Got expected "+e.getClass().getName()+"."); System.out.println(e.getMessage()); } catch (NoSuchMethodError e) { // logback-core version is 1.5.25 or older System.out.println("Got expected "+e.getClass().getName()+"."); System.out.println(e.getMessage()); } } } logback-access-v_2.0.15/logback-access-common-blackbox/src/test/java/module-info.java000066400000000000000000000014611523755721500304650ustar00rootroot00000000000000module ch.qos.logback.access.common.blackbox { requires ch.qos.logback.core; requires ch.qos.logback.access.common; requires org.junit.jupiter.api; requires org.junit.jupiter.engine; requires org.junit.jupiter.params; requires org.assertj.core; requires jakarta.servlet; opens ch.qos.logback.access.common.blackbox.joran to org.junit.platform.commons; opens ch.qos.logback.access.common.blackbox.net to org.junit.platform.commons; opens ch.qos.logback.access.common.blackbox.pattern to org.junit.platform.commons; opens ch.qos.logback.access.common.blackbox.servlet to org.junit.platform.commons; opens ch.qos.logback.access.common.blackbox.spi to org.junit.platform.commons; opens ch.qos.logback.access.common.blackbox.util to org.junit.platform.commons; }logback-access-v_2.0.15/logback-access-common/000077500000000000000000000000001523755721500211305ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/pom.xml000066400000000000000000000075751523755721500224630ustar00rootroot00000000000000 4.0.0 ch.qos.logback.access parent 2.0.15 logback-access-common jar Logback Access Common Module Logback Access Common module org.junit.jupiter junit-jupiter-params ${junit-jupiter-params.version} test ch.qos.logback logback-core compile org.slf4j slf4j-api test ch.qos.logback logback-classic test ch.qos.logback logback-core ${logback-core.version} test-jar test jakarta.servlet jakarta.servlet-api compile jakarta.mail jakarta.mail-api compile true jakarta.activation jakarta.activation-api compile true src/main/resources true ch/qos/logback/access/common/logback-access-common-dependencies.properties ch/qos/logback/access/common/logback-access-common-version.properties org.apache.maven.plugins maven-jar-plugin bundle-test-jar package test-jar org.apache.maven.plugins maven-surefire-plugin --add-modules jakarta.servlet plain true logback-access-v_2.0.15/logback-access-common/src/000077500000000000000000000000001523755721500217175ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/000077500000000000000000000000001523755721500226435ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/000077500000000000000000000000001523755721500235645ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/000077500000000000000000000000001523755721500241565ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/000077500000000000000000000000001523755721500247605ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/000077500000000000000000000000001523755721500263625ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/000077500000000000000000000000001523755721500276235ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/000077500000000000000000000000001523755721500311135ustar00rootroot00000000000000AccessConstants.java000066400000000000000000000031341523755721500347760ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common; 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"; public static final String COOKIE_REQUEST_PROP_KEY = "Cookie"; public static String LOGBACK_ACCESS_COMMON_MODULE_NAME = "logback-access-common"; //public static String LOGBACK_ACCESS_COMMON_NAME = LOGBACK_ACCESS_COMMON_MODULE_NAME; public static String LOGBACK_CORE_MODULE_NAME = "logback-core"; //public static String LOGBACK_CORE_NAME = LOGBACK_CORE_MODULE_NAME; } PatternLayout.java000066400000000000000000000264361523755721500345250ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common; import ch.qos.logback.access.common.pattern.ContentLengthConverter; import ch.qos.logback.access.common.pattern.DateConverter; import ch.qos.logback.access.common.pattern.ElapsedSecondsConverter; import ch.qos.logback.access.common.pattern.ElapsedTimeConverter; import ch.qos.logback.access.common.pattern.EnsureLineSeparation; import ch.qos.logback.access.common.pattern.FullRequestConverter; import ch.qos.logback.access.common.pattern.FullResponseConverter; import ch.qos.logback.access.common.pattern.LineSeparatorConverter; import ch.qos.logback.access.common.pattern.LocalIPAddressConverter; import ch.qos.logback.access.common.pattern.LocalPortConverter; import ch.qos.logback.access.common.pattern.NAConverter; import ch.qos.logback.access.common.pattern.QueryStringConverter; import ch.qos.logback.access.common.pattern.RemoteHostConverter; import ch.qos.logback.access.common.pattern.RemoteIPAddressConverter; import ch.qos.logback.access.common.pattern.RemoteUserConverter; import ch.qos.logback.access.common.pattern.RequestAttributeConverter; import ch.qos.logback.access.common.pattern.RequestContentConverter; import ch.qos.logback.access.common.pattern.RequestCookieConverter; import ch.qos.logback.access.common.pattern.RequestHeaderConverter; import ch.qos.logback.access.common.pattern.RequestMethodConverter; import ch.qos.logback.access.common.pattern.RequestParameterConverter; import ch.qos.logback.access.common.pattern.RequestProtocolConverter; import ch.qos.logback.access.common.pattern.RequestURIConverter; import ch.qos.logback.access.common.pattern.RequestURLConverter; import ch.qos.logback.access.common.pattern.ResponseContentConverter; import ch.qos.logback.access.common.pattern.ResponseHeaderConverter; import ch.qos.logback.access.common.pattern.ServerNameConverter; import ch.qos.logback.access.common.pattern.SessionIDConverter; import ch.qos.logback.access.common.pattern.StatusCodeConverter; import ch.qos.logback.access.common.pattern.ThreadNameConverter; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.pattern.DynamicConverter; 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; import java.util.function.Supplier; /** *

* This class is a module-specific implementation of * {@link 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> ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP = 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 { ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.putAll(Parser.DEFAULT_COMPOSITE_CONVERTER_MAP); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("a", RemoteIPAddressConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("remoteIP", RemoteIPAddressConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("A", LocalIPAddressConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("localIP", LocalIPAddressConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("b", ContentLengthConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("B", ContentLengthConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("bytesSent", ContentLengthConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("h", RemoteHostConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("clientHost", RemoteHostConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("H", RequestProtocolConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("protocol", RequestProtocolConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("i", RequestHeaderConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("header", RequestHeaderConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("I", ThreadNameConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("threadName", ThreadNameConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("l", NAConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("m", RequestMethodConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("requestMethod", RequestMethodConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("q", QueryStringConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("queryString", QueryStringConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("r", RequestURLConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("requestURL", RequestURLConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("s", StatusCodeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("statusCode", StatusCodeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("S", SessionIDConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("sessionID", SessionIDConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("t", DateConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("date", DateConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("u", RemoteUserConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("user", RemoteUserConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("U", RequestURIConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("requestURI", RequestURIConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("v", ServerNameConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("server", ServerNameConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("localPort", LocalPortConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("requestAttribute", RequestAttributeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("reqAttribute", RequestAttributeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("reqCookie", RequestCookieConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("requestCookie", RequestCookieConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("responseHeader", ResponseHeaderConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("requestParameter", RequestParameterConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("reqParameter", RequestParameterConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("requestContent", RequestContentConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("responseContent", ResponseContentConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("fullRequest", FullRequestConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("fullResponse", FullResponseConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("elapsedTime", ElapsedTimeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("D", ElapsedTimeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("elapsedSeconds", ElapsedSecondsConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("T", ElapsedSecondsConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("n", LineSeparatorConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("black", BlackCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("red", RedCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("green", GreenCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("yellow", YellowCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("blue", BlueCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("magenta", MagentaCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("cyan", CyanCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("white", WhiteCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("gray", GrayCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("boldRed", BoldRedCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("boldGreen", BoldGreenCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("boldYellow", BoldYellowCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("boldBlue", BoldBlueCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("boldMagenta", BoldMagentaCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("boldCyan", BoldCyanCompositeConverter::new); ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP.put("boldWhite", BoldWhiteCompositeConverter::new); } 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> getDefaultConverterSupplierMap() { return ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP; } /** * @deprecated Use {@link #getDefaultConverterSupplierMap()} instead. */ @Deprecated public Map getDefaultConverterMap() { return Map.of(); } @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; } } PatternLayoutEncoder.java000066400000000000000000000017511523755721500360160ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common; import ch.qos.logback.access.common.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(); } } ViewStatusMessagesServlet.java000066400000000000000000000033041523755721500370520ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common; 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"; } } logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/boolex/000077500000000000000000000000001523755721500324035ustar00rootroot00000000000000RequestURIEventEvaluator.java000066400000000000000000000042171523755721500400700ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/boolex/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.boolex; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.boolex.EvaluationException; import ch.qos.logback.core.boolex.EventEvaluatorBase; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; /** * A very simple {@link ch.qos.logback.core.boolex.EventEvaluator EventEvaluator} * which checks whether the status of {@link IAccessEvent access event} is equal * to a status code given as a parameter. * * @since 2.0.6 */ public class RequestURIEventEvaluator extends EventEvaluatorBase { String regex; private Pattern pattern; @Override public void start() { if (regex == null) { addError("regex is required"); return; } try { addInfo("Compiling pattern [" + regex + "]"); this.pattern = Pattern.compile(regex); } catch (PatternSyntaxException e) { addError("Invalid regular expression: " + regex); return; } super.start(); } @Override public boolean evaluate(IAccessEvent iAccessEvent) throws NullPointerException, EvaluationException { if (!isStarted()) { throw new IllegalStateException("Evaluator [" + this + "] was called in stopped state"); } String requestURI = iAccessEvent.getRequestURI(); if(requestURI == null) { return false; } java.util.regex.Matcher matcher = pattern.matcher(requestURI); return matcher.find(); } public String getRegex() { return regex; } public void setRegex(String regex) { this.regex = regex; } } StatusCodeEventEvaluator.java000066400000000000000000000033341523755721500401350ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/boolex/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.boolex; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.boolex.EvaluationException; import ch.qos.logback.core.boolex.EventEvaluatorBase; /** * A very simple {@link ch.qos.logback.core.boolex.EventEvaluator EventEvaluator} * which checks whether the status of {@link IAccessEvent access event} is equal * to a status code given as a parameter. * * @since 2.0.6 */ public class StatusCodeEventEvaluator extends EventEvaluatorBase { final static int UNSET = -1; int statusCode = UNSET; @Override public void start() { if(statusCode == UNSET) { addWarn("No status code set"); return; } super.start(); } @Override public boolean evaluate(IAccessEvent iAccessEvent) throws NullPointerException, EvaluationException { if (!isStarted()) { throw new IllegalStateException("Evaluator [" + this + "] was called in stopped state"); } boolean result = (iAccessEvent.getStatusCode() == statusCode); return result; } public int getStatusCode() { return statusCode; } public void setStatusCode(int statusCode) { this.statusCode = statusCode; } } StubEventEvaluator.java000066400000000000000000000027321523755721500367750ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/boolex/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.boolex; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.boolex.EvaluationException; import ch.qos.logback.core.boolex.EventEvaluatorBase; public class StubEventEvaluator extends EventEvaluatorBase { static public final String MSG_0 = "This is a stub for JaninoEventEvaluator which was removed in logback-access version 2.0.5"; static public final String MSG_1 = "You can migrate existing configurations to Java-only equivalents by extending the EventEvaluatorBase class."; String expression; @Override public void start() { stop(); addWarn(MSG_0); addWarn(MSG_1); } @Override public boolean evaluate(IAccessEvent iAccessEvent) throws NullPointerException, EvaluationException { return false; } public String getExpression() { return expression; } public void setExpression(String expression) { this.expression = expression; } } logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/filter/000077500000000000000000000000001523755721500324005ustar00rootroot00000000000000CountingFilter.java000066400000000000000000000044641523755721500361300ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/filter/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.filter; import ch.qos.logback.access.common.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; } } PeriodicStats.java000066400000000000000000000030731523755721500357440ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/filter/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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); } StatisticalView.java000066400000000000000000000015761523755721500363140ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/filter/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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(); } StatisticalViewImpl.java000066400000000000000000000063621523755721500371340ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/filter/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.filter; import ch.qos.logback.core.spi.LifeCycle; public class StatisticalViewImpl implements StatisticalView, LifeCycle { final CountingFilter countingFilter; boolean started; ch.qos.logback.access.common.filter.StatsByMinute statsByMinute = new StatsByMinute(); StatsByHour statsByHour = new StatsByHour(); StatsByDay statsByDay = new StatsByDay(); StatsByWeek statsByWeek = new ch.qos.logback.access.common.filter.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(); } } StatsByDay.java000066400000000000000000000014741523755721500352210ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/filter/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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); } } StatsByHour.java000066400000000000000000000015001523755721500354070ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/filter/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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); } } StatsByMinute.java000066400000000000000000000015101523755721500357340ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/filter/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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); } } StatsByMonth.java000066400000000000000000000015041523755721500355630ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/filter/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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); } } StatsByWeek.java000066400000000000000000000015001523755721500353650ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/filter/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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); } } logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/html/000077500000000000000000000000001523755721500320575ustar00rootroot00000000000000DefaultCssBuilder.java000066400000000000000000000057241523755721500362170ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/html/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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(""); } }HTMLLayout.java000066400000000000000000000056561523755721500346210ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/html/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.html; import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR; import java.util.Map; import java.util.function.Supplier; import ch.qos.logback.access.common.PatternLayout; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.html.HTMLLayoutBase; import ch.qos.logback.core.pattern.Converter; import ch.qos.logback.core.pattern.DynamicConverter; /** * * HTMLLayout outputs events in an HTML table. *

* The content of the table columns are specified using a conversion pattern. * See {@link 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> getDefaultConverterSupplierMap() { return PatternLayout.ACCESS_DEFAULT_CONVERTER_SUPPLIER_MAP; } @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); } } UrlCssBuilder.java000066400000000000000000000022721523755721500353700ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/html/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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(""); } } package.html000066400000000000000000000012451523755721500342630ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/html

Contains classes to format log output in HTML.

logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/joran/000077500000000000000000000000001523755721500322245ustar00rootroot00000000000000JoranConfigurator.java000066400000000000000000000050741523755721500364520ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/joran/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.joran; import ch.qos.logback.access.common.model.processor.LogbackAccessDefaultNestedComponentRegistryRules; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.common.joran.action.ConfigurationAction; 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); } private JoranConfigurator makeAnotherInstance() { JoranConfigurator jc = new JoranConfigurator(); jc.setContext(context); return jc; } public void buildModelInterpretationContext() { super.buildModelInterpretationContext(); this.modelInterpretationContext.setConfiguratorSupplier( () -> this.makeAnotherInstance() ); } } ModelClassToModelHandlerLinker.java000066400000000000000000000041641523755721500407720ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/joran/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.joran; import ch.qos.logback.access.common.model.ConfigurationModel; import ch.qos.logback.access.common.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.*; /** * 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(ConfigurationModel.class, () -> new AppenderRefDependencyAnalyser(context)); defaultProcessor.addAnalyser(AppenderModel.class, () -> new FileCollisionAnalyser(context)); defaultProcessor.addAnalyser(AppenderModel.class, () -> new AppenderDeclarationAnalyser(context)); sealModelFilters(defaultProcessor); } } action/000077500000000000000000000000001523755721500334225ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/joranAccessEvaluatorAction.java000066400000000000000000000012201523755721500405020ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/joran/action/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.joran.action; import ch.qos.logback.core.joran.action.EventEvaluatorAction; public class AccessEvaluatorAction extends EventEvaluatorAction { } ConfigurationAction.java000066400000000000000000000022771523755721500402420ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/joran/action/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.joran.action; import ch.qos.logback.access.common.model.ConfigurationModel; import org.xml.sax.Attributes; 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; } } package.html000066400000000000000000000012401523755721500344230ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/joran

Contains the Joran configuration classes

logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/model/000077500000000000000000000000001523755721500322135ustar00rootroot00000000000000ConfigurationModel.java000066400000000000000000000034001523755721500365640ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/model/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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); } } processor/000077500000000000000000000000001523755721500341535ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/modelConfigurationModelHandler.java000066400000000000000000000046631523755721500421150ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/model/processor/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.model.processor; import ch.qos.logback.access.common.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()); } } } LogbackAccessDefaultNestedComponentRegistryRules.java000066400000000000000000000030711523755721500466020ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/model/processor/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.model.processor; import ch.qos.logback.access.common.PatternLayout; import ch.qos.logback.access.common.PatternLayoutEncoder; import ch.qos.logback.access.common.boolex.StubEventEvaluator; 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(AppenderBase.class, "encoder", PatternLayoutEncoder.class); registry.add(UnsynchronizedAppenderBase.class, "encoder", PatternLayoutEncoder.class); registry.add(EvaluatorFilter.class, "evaluator", StubEventEvaluator.class); SSLNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry); } } logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/net/000077500000000000000000000000001523755721500317015ustar00rootroot00000000000000AccessEventPreSerializationTransformer.java000066400000000000000000000021251523755721500423200ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/net/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.net; import java.io.Serializable; import ch.qos.logback.access.common.spi.AccessEvent; import ch.qos.logback.access.common.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()); } } } HardenedAccessEventInputStream.java000066400000000000000000000024351523755721500405230ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/net/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.net; import java.io.IOException; import java.io.InputStream; import java.io.ObjectStreamClass; import ch.qos.logback.access.common.spi.AccessEvent; import ch.qos.logback.core.Context; import ch.qos.logback.core.net.HardenedObjectInputStream; import jakarta.servlet.http.Cookie; public class HardenedAccessEventInputStream extends HardenedObjectInputStream { static String[] ACCESS_WHITE_LIST = new String[] { AccessEvent.class.getName(), String[].class.getName(), Cookie.class.getName(), "java.util.CollSer", "java.util.TreeMap", "java.lang.String$CaseInsensitiveComparator"}; public HardenedAccessEventInputStream(Context context, InputStream in) throws IOException { super(context, in, ACCESS_WHITE_LIST); } } SMTPAppender.java000066400000000000000000000056331523755721500347360ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/net/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.net; import ch.qos.logback.access.common.PatternLayout; import ch.qos.logback.access.common.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; } } SSLSocketAppender.java000066400000000000000000000025361523755721500357640ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/net/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.net; import ch.qos.logback.access.common.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; } } SimpleSocketServer.java000066400000000000000000000060541523755721500362630ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/net/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.net; import java.net.ServerSocket; import java.net.Socket; import ch.qos.logback.access.common.spi.AccessContext; import ch.qos.logback.access.common.joran.JoranConfigurator; 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); } } } SocketAppender.java000066400000000000000000000027321523755721500354000ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/net/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.net; import ch.qos.logback.access.common.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; } } SocketNode.java000066400000000000000000000056621523755721500345340ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/net/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.net; import java.io.BufferedInputStream; import java.io.IOException; import java.net.Socket; import ch.qos.logback.access.common.spi.AccessContext; import ch.qos.logback.access.common.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(context, 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); } } } URLEvaluator.java000066400000000000000000000035751523755721500350240ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/net/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.net; import java.util.ArrayList; import java.util.List; import ch.qos.logback.access.common.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; } } package.html000066400000000000000000000012341523755721500333150ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common

This is logback access' main package.

logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/000077500000000000000000000000001523755721500325705ustar00rootroot00000000000000AccessConverter.java000066400000000000000000000035621523755721500364530ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.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); } } ContentLengthConverter.java000066400000000000000000000017001523755721500400160ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; /** * The content length of the bytes sent. */ 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); } } } DateConverter.java000066400000000000000000000060311523755721500361210ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import java.time.ZoneId; import java.util.List; import java.util.Locale; import ch.qos.logback.access.common.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; } else if (datePattern.equals(CoreConstants.ISO8601_STR)) { datePattern = CoreConstants.ISO8601_PATTERN; } else if (datePattern.equals(CoreConstants.STRICT_STR)) { datePattern = CoreConstants.STRICT_ISO8601_PATTERN; } List optionList = getOptionList(); ZoneId zoneId = null; // 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); } Locale locale = null; if (optionList != null && optionList.size() > 2) { String localeIdStr = (String) optionList.get(2); locale = Locale.forLanguageTag(localeIdStr); addInfo("Setting locale to \""+locale+"\""); } try { // if zoneId is null, the CachingDateFormatter will use the ZoneId.systemDefault() // if locale is null, the CachingDateFormatter will use the Locale.getDefault() cachingDateFormatter = new CachingDateFormatter(datePattern, zoneId, locale); } 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); } super.start(); } @Override public String convert(IAccessEvent accessEvent) { long timestamp = accessEvent.getTimeStamp(); return cachingDateFormatter.format(timestamp); } /** * This method is intended for test classes. Should not be used * by regular clients. * * @return the CachingDateFormatter in use * @deprecated Will be removed in future versions with no replacement */ @Deprecated public CachingDateFormatter internalCachingDateFormatter() { return cachingDateFormatter; } } ElapsedSecondsConverter.java000066400000000000000000000013741523755721500401450ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; public class ElapsedSecondsConverter extends AccessConverter { public String convert(IAccessEvent accessEvent) { return Long.toString(accessEvent.getElapsedSeconds()); } } ElapsedTimeConverter.java000066400000000000000000000014041523755721500374370ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; public class ElapsedTimeConverter extends AccessConverter { @Override public String convert(IAccessEvent accessEvent) { return Long.toString(accessEvent.getElapsedTime()); } } EnsureLineSeparation.java000066400000000000000000000030041523755721500374500ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.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 ch.qos.logback.access.common.pattern.LineSeparatorConverter(); if (!(tail instanceof ch.qos.logback.access.common.pattern.LineSeparatorConverter)) { tail.setNext(newLineConverter); } } } FullRequestConverter.java000066400000000000000000000032531523755721500375220ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import java.util.Enumeration; import ch.qos.logback.access.common.PatternLayout; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.CoreConstants; /** * This class is tied to the fullRequest conversion word. *

* It has been removed from the {@link 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(); } } FullResponseConverter.java000066400000000000000000000074041523755721500376720ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import java.util.List; import ch.qos.logback.access.common.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"; } } } LineSeparatorConverter.java000066400000000000000000000014321523755721500400140ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.CoreConstants; public class LineSeparatorConverter extends AccessConverter { @Override public String convert(IAccessEvent event) { return CoreConstants.LINE_SEPARATOR; } } LocalIPAddressConverter.java000066400000000000000000000020751523755721500400410ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import java.net.InetAddress; import java.net.UnknownHostException; import ch.qos.logback.access.common.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; } } LocalPortConverter.java000066400000000000000000000014021523755721500371400ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; public class LocalPortConverter extends AccessConverter { @Override public String convert(IAccessEvent accessEvent) { return Integer.toString(accessEvent.getLocalPort()); } } NAConverter.java000066400000000000000000000015551523755721500355500ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.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; } } QueryStringConverter.java000066400000000000000000000013461523755721500375440ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; public class QueryStringConverter extends AccessConverter { public String convert(IAccessEvent accessEvent) { return accessEvent.getQueryString(); } } RemoteHostConverter.java000066400000000000000000000013631523755721500373400ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; public class RemoteHostConverter extends AccessConverter { @Override public String convert(IAccessEvent accessEvent) { return accessEvent.getRemoteHost(); } } RemoteIPAddressConverter.java000066400000000000000000000013701523755721500402370ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; public class RemoteIPAddressConverter extends AccessConverter { @Override public String convert(IAccessEvent accessEvent) { return accessEvent.getRemoteAddr(); } } RemoteUserConverter.java000066400000000000000000000015571523755721500373460ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.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; } } } RequestAttributeConverter.java000066400000000000000000000022061523755721500405600ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.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); } } RequestContentConverter.java000066400000000000000000000020761523755721500402340ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.PatternLayout; import ch.qos.logback.access.common.spi.IAccessEvent; /** * This class is tied to the requestContent conversion word. *

* It has been removed from the {@link 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(); } } RequestCookieConverter.java000066400000000000000000000021731523755721500400310ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.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); } } RequestHeaderConverter.java000066400000000000000000000024251523755721500400100ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.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(); } } } RequestMethodConverter.java000066400000000000000000000013611523755721500400360ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; public class RequestMethodConverter extends AccessConverter { @Override public String convert(IAccessEvent accessEvent) { return accessEvent.getMethod(); } } RequestParameterConverter.java000066400000000000000000000027201523755721500405360ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import java.util.Arrays; import ch.qos.logback.access.common.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); } } } RequestProtocolConverter.java000066400000000000000000000013651523755721500404230ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; public class RequestProtocolConverter extends AccessConverter { @Override public String convert(IAccessEvent accessEvent) { return accessEvent.getProtocol(); } } RequestURIConverter.java000066400000000000000000000014631523755721500372600ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; /** * The request URI. * * @author Ceki Gülcü */ public class RequestURIConverter extends AccessConverter { @Override public String convert(IAccessEvent accessEvent) { return accessEvent.getRequestURI(); } } RequestURLConverter.java000066400000000000000000000015001523755721500372530ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.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(); } } ResponseContentConverter.java000066400000000000000000000021001523755721500403660ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.PatternLayout; import ch.qos.logback.access.common.spi.IAccessEvent; /** * This class is tied to the requestContent conversion word. *

* It has been removed from the {@link 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(); } } ResponseHeaderConverter.java000066400000000000000000000026751523755721500401650ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.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(); // } } } ServerNameConverter.java000066400000000000000000000013621523755721500373150ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; public class ServerNameConverter extends AccessConverter { @Override public String convert(IAccessEvent accessEvent) { return accessEvent.getServerName(); } } SessionIDConverter.java000066400000000000000000000014371523755721500371110ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.pattern.AccessConverter; import ch.qos.logback.access.common.spi.IAccessEvent; public class SessionIDConverter extends AccessConverter { public String convert(IAccessEvent accessEvent) { return accessEvent.getSessionID(); } } StatusCodeConverter.java000066400000000000000000000015021523755721500373200ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.pattern.AccessConverter; import ch.qos.logback.access.common.spi.IAccessEvent; public class StatusCodeConverter extends AccessConverter { @Override public String convert(IAccessEvent accessEvent) { return Integer.toString(accessEvent.getStatusCode()); } } ThreadNameConverter.java000066400000000000000000000013451523755721500372570ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.pattern; import ch.qos.logback.access.common.spi.IAccessEvent; public class ThreadNameConverter extends AccessConverter { public String convert(IAccessEvent accessEvent) { return accessEvent.getThreadName(); } } package.html000066400000000000000000000012761523755721500350000ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/pattern

Provides classes implementing format specifiers in conversion patterns.

logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/servlet/000077500000000000000000000000001523755721500325775ustar00rootroot00000000000000TeeFilter.java000066400000000000000000000112601523755721500352460ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/servlet/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.servlet; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; import ch.qos.logback.access.common.AccessConstants; 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; 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(AccessConstants.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(AccessConstants.TEE_FILTER_INCLUDES_PARAM); String excludeListAsStr = filterConfig.getInitParameter(AccessConstants.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 + "]"); } public 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; } public 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); } } TeeHttpServletRequest.java000066400000000000000000000046571523755721500376720ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/servlet/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.servlet; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import ch.qos.logback.access.common.AccessConstants; import jakarta.servlet.ServletInputStream; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequestWrapper; /** * 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(AccessConstants.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; } } TeeHttpServletResponse.java000066400000000000000000000044061523755721500400300ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/servlet/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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(); } } } TeeServletInputStream.java000066400000000000000000000047251523755721500376510ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/servlet/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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"); } } TeeServletOutputStream.java000066400000000000000000000061121523755721500400420ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/servlet/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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"); } } Util.java000066400000000000000000000025641523755721500343070ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/servlet/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.servlet; import ch.qos.logback.access.common.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; } } } logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/sift/000077500000000000000000000000001523755721500320605ustar00rootroot00000000000000AccessEventDiscriminator.java000066400000000000000000000125301523755721500376000ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/sift/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.sift; import ch.qos.logback.access.common.spi.IAccessEvent; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpSession; 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; } } SiftingAppender.java000066400000000000000000000030121523755721500357220ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/sift/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.sift; import ch.qos.logback.access.common.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); } } logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/spi/000077500000000000000000000000001523755721500317065ustar00rootroot00000000000000AccessContext.java000066400000000000000000000054371523755721500352510ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/spi/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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); } } AccessEvent.java000066400000000000000000000470231523755721500347030ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/spi/** * 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.common.spi; import ch.qos.logback.access.common.AccessConstants; import ch.qos.logback.access.common.pattern.AccessConverter; import ch.qos.logback.access.common.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.Arrays; 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) /** *

This class is the implementation of the {@link IAccessEvent} interface.

* *

Much of the processing done by the logack-access project revolves around this class.

* * @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; List cookieList; 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) return requestURL; if (httpRequest != null) { StringBuilder buf = new StringBuilder(); buf.append(getMethod()); buf.append(AccessConverter.SPACE_CHAR); buf.append(getRequestURI()); buf.append(getQueryString()); buf.append(AccessConverter.SPACE_CHAR); buf.append(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) { if (httpRequest instanceof WrappedHttpRequest) { WrappedHttpRequest wrappedHttpRequest = (WrappedHttpRequest) httpRequest; sessionID = wrappedHttpRequest.getSessionID(); } else { 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() { if (httpRequest instanceof WrappedHttpRequest) { WrappedHttpRequest whr = (WrappedHttpRequest) httpRequest; requestHeaderMap = whr.buildRequestHeaderMap(); } else { // 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() { if (httpRequest instanceof WrappedHttpRequest) { WrappedHttpRequest whr = (WrappedHttpRequest) httpRequest; requestParameterMap = whr.buildRequestParameterMap(); } else { 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; } /** * Return the list of cookies in the httpRequest. The list is created if it did not exist previously. * * @return a list of cookies in the httpRequest, the returned list can be empty but not null * @since version 2.0.2 */ public List getCookies() { if (cookieList != null) return cookieList; if (httpRequest == null) { cookieList = List.of(); return cookieList; } Cookie[] cookieArray = httpRequest.getCookies(); this.cookieList = (cookieArray != null ? List.of(cookieArray) : List.of()); return this.cookieList; } @Override public String getCookie(String key) { List cookies = getCookies(); Cookie matchingCookie = cookies.stream().filter(c -> c.getName().equals(key)).findFirst().orElse(null); return matchingCookie != null ? matchingCookie.getValue() : 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(); getCookies(); getStatusCode(); getContentLength(); getRequestContent(); getResponseContent(); copyAttributeMap(); } } IAccessEvent.java000066400000000000000000000075341523755721500350170ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/spi/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.spi; import ch.qos.logback.core.spi.DeferredProcessingAware; import jakarta.servlet.http.Cookie; 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) /** *

This class is the internal representation of events to be logged. *

* *

When the HTTP container wishes to log an HTTP access event, then * an instance of this class is created. This instance is passed around * to the different logback components. *

* *

Put differently, the logback-access project revolves around this interface.

* * @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); /** *

Return a list of cookies in the httpRequest. The list is immutable and is created if * it did not exist previously. *

* *

The default implementation returns an immutable empty list. *

* * @return an immutable list of cookies in the httpRequest, the returned list can be empty but not null * @since version 2.0.2 */ default List getCookies() { return List.of(); } String getCookie(String key); long getContentLength(); int getStatusCode(); String getRequestContent(); String getResponseContent(); int getLocalPort(); ServerAdapter getServerAdapter(); String getResponseHeader(String key); Map getResponseHeaderMap(); List getResponseHeaderNameList(); } ServerAdapter.java000066400000000000000000000015651523755721500352500ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/spi/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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(); } Util.java000066400000000000000000000020571523755721500334130ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/spi/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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(); } } WrappedHttpRequest.java000066400000000000000000000013111523755721500363010ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/spi/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.spi; import java.util.Map; public interface WrappedHttpRequest { String getSessionID(); Map buildRequestHeaderMap(); Map buildRequestParameterMap(); } package.html000066400000000000000000000012431523755721500341100ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/spi

Contains the core classes of logback access.

logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/util/000077500000000000000000000000001523755721500320705ustar00rootroot00000000000000AccessCommonVersionUtil.java000066400000000000000000000066331523755721500374420ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/java/ch/qos/logback/access/common/util/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.util; import ch.qos.logback.access.common.AccessConstants; import ch.qos.logback.core.Context; import ch.qos.logback.core.util.VersionUtil; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import static ch.qos.logback.access.common.AccessConstants.LOGBACK_ACCESS_COMMON_MODULE_NAME; /** * Utility class for retrieving version information about the "logback-access-common" module * based on the self-declared properties file. * * * @since 2.0.9 */ public class AccessCommonVersionUtil extends VersionUtil { static String LOGBACK_ACCESS_COMMON_MODULE_VERSION_PROPERTIES_FILE = LOGBACK_ACCESS_COMMON_MODULE_NAME + "-version.properties"; static String LOGBACK_ACCESS_COMMON_MODULE_VERSION_PROPERTY_KEY = LOGBACK_ACCESS_COMMON_MODULE_NAME + "-version"; public AccessCommonVersionUtil(Context context) { super(context); } static public String getAccessCommonVersionBySelfDeclaredProperties() { Properties props = new Properties(); try (InputStream is = AccessConstants.class.getResourceAsStream(LOGBACK_ACCESS_COMMON_MODULE_VERSION_PROPERTIES_FILE)) { if (is != null) { props.load(is); return props.getProperty(LOGBACK_ACCESS_COMMON_MODULE_VERSION_PROPERTY_KEY); } else { return null; } } catch (IOException e) { return null; } } /** * Retrieves the expected version of a specific dependency from a properties file * located in the classpath of the specified depender class. The dependency version * is determined based on the key provided. * * @param dependerClass the class whose classloader is used to locate the properties file * @param propertiesFileName the name of the properties file containing dependency information * @param dependencyNameAsKey the key in the properties file representing the desired dependency * @return the version of the dependency as specified in the properties file, or null if the file * or key is not found, or an error occurs during processing * * @since 2.0.10 */ @Override public String getExpectedVersionOfDependencyByProperties(Class dependerClass, String propertiesFileName, String dependencyNameAsKey) { Properties props = new Properties(); // propertiesFileName : logback-access-common-dependencies.properties // Class.getResourceAsStream invokes Class.isOpenToCaller(name, Reflection.getCallerClass()) // Thus, the caller class must be in the same module try (InputStream is = dependerClass.getResourceAsStream(propertiesFileName)) { if (is != null) { props.load(is); return props.getProperty(dependencyNameAsKey); } else { return null; } } catch (IOException e) { return null; } } } logback-access-v_2.0.15/logback-access-common/src/main/java/module-info.java000066400000000000000000000015321523755721500266460ustar00rootroot00000000000000module ch.qos.logback.access.common { requires ch.qos.logback.core; // jakarta.servlet 5.0 is not modular but 6.0 is requires static jakarta.servlet; requires static java.management; exports ch.qos.logback.access.common; exports ch.qos.logback.access.common.boolex; exports ch.qos.logback.access.common.filter; exports ch.qos.logback.access.common.html; exports ch.qos.logback.access.common.joran; exports ch.qos.logback.access.common.joran.action; exports ch.qos.logback.access.common.model; exports ch.qos.logback.access.common.model.processor; exports ch.qos.logback.access.common.net; exports ch.qos.logback.access.common.pattern; exports ch.qos.logback.access.common.util; exports ch.qos.logback.access.common.servlet; exports ch.qos.logback.access.common.sift; exports ch.qos.logback.access.common.spi; } logback-access-v_2.0.15/logback-access-common/src/main/resources/000077500000000000000000000000001523755721500246555ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/resources/ch/000077500000000000000000000000001523755721500252475ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/resources/ch/qos/000077500000000000000000000000001523755721500260515ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/resources/ch/qos/logback/000077500000000000000000000000001523755721500274535ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/resources/ch/qos/logback/access/000077500000000000000000000000001523755721500307145ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/resources/ch/qos/logback/access/common/000077500000000000000000000000001523755721500322045ustar00rootroot00000000000000logback-access-common-dependencies.properties000066400000000000000000000000451523755721500430150ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/resources/ch/qos/logback/access/commonlogback-core=${logback-core.version} logback-access-common-version.properties000066400000000000000000000007731523755721500420640ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/main/resources/ch/qos/logback/access/common# # Logback: the reliable, generic, fast and flexible logging framework. # Copyright (C) 1999-2026, QOS.ch. All rights reserved. # # This program and the accompanying materials are dual-licensed under # either the terms of the Eclipse Public License v2.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. # logback-access-common-version=${project.version}logback-access-v_2.0.15/logback-access-common/src/test/000077500000000000000000000000001523755721500226765ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/java/000077500000000000000000000000001523755721500236175ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/java/ch/000077500000000000000000000000001523755721500242115ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/000077500000000000000000000000001523755721500250135ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/logback/000077500000000000000000000000001523755721500264155ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/logback/access/000077500000000000000000000000001523755721500276565ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/logback/access/common/000077500000000000000000000000001523755721500311465ustar00rootroot00000000000000AccessTestConstants.java000066400000000000000000000013621523755721500356720ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/logback/access/common/** * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2024, 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.common; 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/"; } logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/logback/access/common/filter/000077500000000000000000000000001523755721500324335ustar00rootroot00000000000000StatsByDayTest.java000066400000000000000000000046521523755721500361150ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/logback/access/common/filter/** * 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.common.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); } } logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/logback/access/common/joran/000077500000000000000000000000001523755721500322575ustar00rootroot00000000000000ConditionalTest.java000066400000000000000000000072101523755721500361460ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/logback/access/common/joran/** * 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.common.joran; import ch.qos.logback.access.common.AccessTestConstants; import ch.qos.logback.access.common.spi.AccessContext; import ch.qos.logback.access.common.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)); } } logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/logback/access/common/testUtil/000077500000000000000000000000001523755721500327635ustar00rootroot00000000000000HttpGetUtil.java000066400000000000000000000067101523755721500357700ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/logback/access/common/testUtil/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2024, 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.common.testUtil; import org.slf4j.LoggerFactory; import org.slf4j.Logger; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.StandardCharsets; import static ch.qos.logback.access.common.AccessConstants.COOKIE_REQUEST_PROP_KEY; public class HttpGetUtil { Logger logger = LoggerFactory.getLogger(this.getClass()); URL url; HttpURLConnection conn; public HttpGetUtil(String urlStr) throws MalformedURLException { this.url = new URL(urlStr); } String requestMethod = "GET"; public HttpGetUtil init() { if(conn != null) { throw new IllegalStateException("Already initialized"); } try { this.conn = (HttpURLConnection) url.openConnection(); this.conn.setRequestMethod(requestMethod); return this; } catch (IOException e) { logger.atError().addKeyValue("url", url.toString()).setCause(e).log("Failed to connect"); return this; } } public HttpGetUtil addRequestProperty(String key, String val) { this.conn.addRequestProperty(key, val); return this; } public HttpGetUtil addCookie(String val) { return addRequestProperty(COOKIE_REQUEST_PROP_KEY, val); } public HttpURLConnection connect() { try { conn.connect(); return conn; } catch (IOException e) { logger.atError().addKeyValue("url", url.toString()).setCause(e).log("Failed to connect"); return null; } } public String readResponse() { if(conn == null) return null; try { int responseCode = conn.getResponseCode(); if(responseCode == HttpURLConnection.HTTP_OK) { return innerReadResponse(); } else { logger.atError().addKeyValue("status", responseCode).log("Failed response"); return null; } } catch (IOException e) { logger.atError().addKeyValue("url", url.toString()).setCause(e).log("failed to read status"); return null; } } private String innerReadResponse() { try (InputStream is = conn.getInputStream()) { BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); String inputLine; StringBuffer buffer = new StringBuffer(); while ((inputLine = in.readLine()) != null) { buffer.append(inputLine); } return buffer.toString(); } catch (IOException e) { logger.atError().addKeyValue("url", url.toString()).setCause(e).log("failed"); return null; } } public void disconnect() { if(conn != null) conn.disconnect(); } } NotifyingListAppender.java000066400000000000000000000016731523755721500400370ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/java/ch/qos/logback/access/common/testUtil/** * 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.common.testUtil; import java.util.concurrent.LinkedBlockingQueue; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.AppenderBase; public class NotifyingListAppender extends AppenderBase { public final LinkedBlockingQueue list = new LinkedBlockingQueue(); protected void append(IAccessEvent e) { e.prepareForDeferredProcessing(); list.add(e); } } logback-access-v_2.0.15/logback-access-common/src/test/resources/000077500000000000000000000000001523755721500247105ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-common/src/test/resources/logback-asResource.xml000066400000000000000000000005231523755721500311450ustar00rootroot00000000000000 %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-jetty11-blackbox/000077500000000000000000000000001523755721500227245ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11-blackbox/pom.xml000066400000000000000000000064201523755721500242430ustar00rootroot00000000000000 4.0.0 ch.qos.logback.access parent 2.0.15 logback-access-jetty11_blackbox jar Logback Access Jetty 11 Blackbox Module Logback Access Jetty 11 Blackbox module org.assertj assertj-core ${assertj-core.version} org.junit.jupiter junit-jupiter-api ${junit-jupiter-api.version} org.junit.jupiter junit-jupiter-engine ${junit-jupiter-api.version} org.hamcrest hamcrest-library ${hamcrest.version} org.junit.jupiter junit-jupiter-params ${junit-jupiter-params.version} ch.qos.logback logback-core compile ch.qos.logback logback-classic ch.qos.logback logback-core ${logback-core.version} test-jar ch.qos.logback.access logback-access-common ch.qos.logback.access logback-access-common ${project.version} test-jar ch.qos.logback.access logback-access-jetty11 ${project.version} org.eclipse.jetty jetty-server ${jetty11.version} org.slf4j slf4j-api org.apache.maven.plugins maven-surefire-plugin once plain true logback-access-v_2.0.15/logback-access-jetty11-blackbox/src/000077500000000000000000000000001523755721500235135ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11-blackbox/src/test/000077500000000000000000000000001523755721500244725ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11-blackbox/src/test/java/000077500000000000000000000000001523755721500254135ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11-blackbox/src/test/java/ch/000077500000000000000000000000001523755721500260055ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11-blackbox/src/test/java/ch/qos/000077500000000000000000000000001523755721500266075ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11-blackbox/src/test/java/ch/qos/acccess/000077500000000000000000000000001523755721500302135ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11-blackbox/src/test/java/ch/qos/acccess/jetty11/000077500000000000000000000000001523755721500315145ustar00rootroot00000000000000blackbox/000077500000000000000000000000001523755721500332225ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11-blackbox/src/test/java/ch/qos/acccess/jetty11Jetty11VersionUtilTest.java000066400000000000000000000017571523755721500404040ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11-blackbox/src/test/java/ch/qos/acccess/jetty11/blackbox/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.acccess.jetty11.blackbox; import ch.qos.logback.access.jetty.Jetty11VersionUtil; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class Jetty11VersionUtilTest { @Test public void smoke() { String jetty12Version = Jetty11VersionUtil.getAccessJetty11VersionBySelfDeclaredProperties(); assertNotNull(jetty12Version); assertTrue(jetty12Version.startsWith("2.0")); } } logback-access-v_2.0.15/logback-access-jetty11/000077500000000000000000000000001523755721500211415ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/pom.xml000066400000000000000000000053371523755721500224660ustar00rootroot00000000000000 4.0.0 ch.qos.logback.access parent 2.0.15 logback-access-jetty11 jar Logback Access Jetty 11 Module Logback Access Jetty 11 Module ch.qos.logback.access logback-access-common ch.qos.logback.access logback-access-common ${project.version} test-jar test ch.qos.logback logback-core ${logback-core.version} test-jar test org.eclipse.jetty jetty-server ${jetty11.version} src/main/resources true ch/qos/logback/access/jetty/logback-access-jetty11-version.properties org.apache.maven.plugins maven-surefire-plugin once plain true **/AllAccessTest.java **/PackageTest.java **/SerializationPerfTest.java logback-access-v_2.0.15/logback-access-jetty11/src/000077500000000000000000000000001523755721500217305ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/000077500000000000000000000000001523755721500226545ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/000077500000000000000000000000001523755721500235755ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/000077500000000000000000000000001523755721500241675ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/000077500000000000000000000000001523755721500247715ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/logback/000077500000000000000000000000001523755721500263735ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/logback/access/000077500000000000000000000000001523755721500276345ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/logback/access/jetty/000077500000000000000000000000001523755721500307735ustar00rootroot00000000000000HeaderUtil.java000066400000000000000000000030721523755721500336070ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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 org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import java.util.Map; import java.util.TreeMap; /** *

A utility class that builds a map from HttpFields (headers).

* *

In case a homonymous header exists, it is merged into the existing value by concatenation.

* * @author Ceki Gülcü * @author Robert Elliot * @since 2.0.7 */ class HeaderUtil { static Map buildHeaderMap(HttpFields.Mutable headers) { Map requestHeaderMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); for (HttpField httpField : headers) { String existing = requestHeaderMap.get(httpField.getName()); String value = combine(existing, httpField.getValue()); requestHeaderMap.put(httpField.getName(), value); } return requestHeaderMap; } private static String combine(String existing, String field) { if (existing == null) { return field; } else { return existing + "," + field; } } } Jetty11Constants.java000066400000000000000000000011631523755721500347160ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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; public class Jetty11Constants { static String LOGBACK_ACCESS_JETTY11_MODULE_NAME = "logback-access-jetty11"; } Jetty11VersionUtil.java000066400000000000000000000030001523755721500352150ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.InputStream; import java.util.Properties; import static ch.qos.logback.access.jetty.Jetty11Constants.LOGBACK_ACCESS_JETTY11_MODULE_NAME; public class Jetty11VersionUtil { static String LOGBACK_ACCESS_JETTY11_MODULE_VERSION_PROPERTIES_FILE = LOGBACK_ACCESS_JETTY11_MODULE_NAME + "-version.properties"; static String LOGBACK_ACCESS_JETTY11_MODULE_VERSION_PROPERTY_KEY = LOGBACK_ACCESS_JETTY11_MODULE_NAME + "-version"; static public String getAccessJetty11VersionBySelfDeclaredProperties() { Properties props = new Properties(); try (InputStream is = Jetty11Constants.class.getResourceAsStream(LOGBACK_ACCESS_JETTY11_MODULE_VERSION_PROPERTIES_FILE)) { if (is != null) { props.load(is); return props.getProperty(LOGBACK_ACCESS_JETTY11_MODULE_VERSION_PROPERTY_KEY); } else { return null; } } catch (IOException e) { return null; } } } JettyModernServerAdapter.java000066400000000000000000000037351523755721500365230ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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; } } JettyServerAdapter.java000066400000000000000000000030551523755721500353510ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.spi.ServerAdapter; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Response; import java.util.Map; import static ch.qos.logback.access.jetty.HeaderUtil.buildHeaderMap; /** * 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() { return buildHeaderMap(response.getHttpFields()); } } RequestLogImpl.java000066400000000000000000000444761523755721500345120ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.AccessConstants; import ch.qos.logback.access.common.joran.JoranConfigurator; import ch.qos.logback.access.common.spi.AccessEvent; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.common.util.AccessCommonVersionUtil; 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.status.WarnStatus; import ch.qos.logback.core.util.CoreVersionUtil; import ch.qos.logback.core.util.FileUtil; import ch.qos.logback.core.util.OptionHelper; import ch.qos.logback.core.util.StatusPrinter; import ch.qos.logback.core.util.VersionUtil; 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; 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 static ch.qos.logback.core.CoreConstants.DEFAULT_CONTEXT_NAME; /** * 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() { setName(DEFAULT_CONTEXT_NAME); 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)); } protected void addWarn(String msg) { getStatusManager().add(new WarnStatus(msg, this)); } private void addError(String msg) { getStatusManager().add(new ErrorStatus(msg, this)); } @Override public void start() { state = State.STARTING; versionCheck(); try { configure(); if (!isQuiet()) { StatusPrinter.print(getStatusManager()); } state = State.STARTED; } catch (Throwable t) { t.printStackTrace(); state = State.FAILED; } } static String LOGBACK_ACCESS_JETTY11_NAME = "logback-access-jetty11"; static String LOGBACK_ACCESS_COMMON_NAME = "logback-access-common"; static String LOGBACK_CORE_NAME = "logback-core"; private void versionCheck() { try { String coreVersion = CoreVersionUtil.getCoreVersionBySelfDeclaredProperties(); String accessCommonVersion = AccessCommonVersionUtil.getAccessCommonVersionBySelfDeclaredProperties(); String accessJetty11Version = Jetty11VersionUtil.getAccessJetty11VersionBySelfDeclaredProperties(); VersionUtil.checkForVersionEquality(this, accessJetty11Version, accessCommonVersion, LOGBACK_ACCESS_JETTY11_NAME, LOGBACK_ACCESS_COMMON_NAME); AccessCommonVersionUtil accessCommonVersionUtil = new AccessCommonVersionUtil(this); accessCommonVersionUtil.compareExpectedAndFoundVersion(coreVersion, AccessConstants.class, accessCommonVersion, LOGBACK_ACCESS_COMMON_NAME, LOGBACK_CORE_NAME); } catch(NoClassDefFoundError e) { addWarn("Missing ch.logback.core.util.VersionUtil class on classpath. The version of logback-core is probably earlier than 1.5.25."); } catch(NoSuchMethodError e) { addWarn(e.getMessage() + ". The version of logback-core is probably earlier than 1.5.26."); } } 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 } } RequestLogRegistry.java000066400000000000000000000017341523755721500354070ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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); } } package.html000066400000000000000000000012521523755721500331750ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/java/ch/qos/logback/access/jetty

This is logback access' implementation for Jetty 8.

logback-access-v_2.0.15/logback-access-jetty11/src/main/java/module-info.DISABLED000066400000000000000000000002631523755721500271050ustar00rootroot00000000000000module ch.qos.logback.access { requires ch.qos.logback.core; // jakarta.servlet 5.0 is not modular requires static jakarta.servlet; requires static java.management; } logback-access-v_2.0.15/logback-access-jetty11/src/main/resources/000077500000000000000000000000001523755721500246665ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/resources/ch/000077500000000000000000000000001523755721500252605ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/resources/ch/qos/000077500000000000000000000000001523755721500260625ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/resources/ch/qos/logback/000077500000000000000000000000001523755721500274645ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/resources/ch/qos/logback/access/000077500000000000000000000000001523755721500307255ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/resources/ch/qos/logback/access/jetty/000077500000000000000000000000001523755721500320645ustar00rootroot00000000000000logback-access-jetty11-version.properties000066400000000000000000000000611523755721500417430ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/main/resources/ch/qos/logback/access/jettylogback-access-jetty11-version=${project.version}logback-access-v_2.0.15/logback-access-jetty11/src/test/000077500000000000000000000000001523755721500227075ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/input/000077500000000000000000000000001523755721500240465ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/input/jetty/000077500000000000000000000000001523755721500252055ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/input/jetty/sifting.xml000066400000000000000000000006371523755721500274000ustar00rootroot00000000000000 uri REQUEST_URI NA logback-access-v_2.0.15/logback-access-jetty11/src/test/input/joran/000077500000000000000000000000001523755721500251575ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/input/joran/conditional/000077500000000000000000000000001523755721500274625ustar00rootroot00000000000000conditionalConsole.xml000066400000000000000000000005361523755721500337570ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/input/joran/conditional %h %l %u %user %date "%r" %s %b conditionalConsole_ELSE.xml000066400000000000000000000007371523755721500345720ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/input/joran/conditional %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-jetty11/src/test/input/joran/defaultLayout.xml000066400000000000000000000005361523755721500305270ustar00rootroot00000000000000 %requestMethod logback-access-v_2.0.15/logback-access-jetty11/src/test/input/joran/smoke.xml000066400000000000000000000002101523755721500270100ustar00rootroot00000000000000 logback-access-v_2.0.15/logback-access-jetty11/src/test/input/joran/tomcat/000077500000000000000000000000001523755721500264465ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/input/joran/tomcat/logback-access.xml000066400000000000000000000005231523755721500320310ustar00rootroot00000000000000 %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-jetty11/src/test/java/000077500000000000000000000000001523755721500236305ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/java/ch/000077500000000000000000000000001523755721500242225ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/java/ch/qos/000077500000000000000000000000001523755721500250245ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/java/ch/qos/logback/000077500000000000000000000000001523755721500264265ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/java/ch/qos/logback/access/000077500000000000000000000000001523755721500276675ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/java/ch/qos/logback/access/jetty/000077500000000000000000000000001523755721500310265ustar00rootroot00000000000000Jetty11BasicTest.java000066400000000000000000000130711523755721500346570ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/java/ch/qos/logback/access/jetty/** * 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.common.testUtil.HttpGetUtil; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.common.testUtil.NotifyingListAppender; import ch.qos.logback.core.testUtil.RandomUtil; import jakarta.servlet.http.Cookie; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.HttpURLConnection; import java.net.URL; import java.util.List; import java.util.concurrent.TimeUnit; import static ch.qos.logback.access.jetty.JettyFixtureBase.HELLO_WORLD_MSG; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; public class Jetty11BasicTest { private static final int TIMEOUT_IN_SECONDS = 3; RequestLogImpl REQUEST_LOG_IMPL; JettyFixtureWithListAndConsoleAppenders JETTY_FIXTURE; String JETTY_FIXTURE_URL_STR; int RANDOM_SERVER_PORT = RandomUtil.getRandomServerPort(); HttpGetUtil httpGetUtil; @BeforeEach @Timeout(value = TIMEOUT_IN_SECONDS, unit = TimeUnit.SECONDS) public void startServer() throws Exception { REQUEST_LOG_IMPL = new RequestLogImpl(); JETTY_FIXTURE = new JettyFixtureWithListAndConsoleAppenders(REQUEST_LOG_IMPL, RANDOM_SERVER_PORT); JETTY_FIXTURE.start(); JETTY_FIXTURE_URL_STR = JETTY_FIXTURE.getUrl(); Thread.sleep(100); } @AfterEach public void stopServer() throws Exception { if(this.httpGetUtil != null) { this.httpGetUtil.disconnect(); } if (JETTY_FIXTURE != null) { JETTY_FIXTURE.stop(); } } @Test public void getRequest() throws Exception { this.httpGetUtil = new HttpGetUtil("http://localhost:" + RANDOM_SERVER_PORT + "/"); this.httpGetUtil = this.httpGetUtil.init(); this.httpGetUtil.connect(); String result = this.httpGetUtil.readResponse(); assertEquals(HELLO_WORLD_MSG, result); NotifyingListAppender listAppender = (NotifyingListAppender) REQUEST_LOG_IMPL.getAppender("list"); listAppender.list.clear(); } @Test public void eventGoesToAppenders() throws Exception { this.httpGetUtil = new HttpGetUtil(JETTY_FIXTURE_URL_STR + "path/foo%20bar;param?query#fragment"); this.httpGetUtil = httpGetUtil.init().addCookie("k0=v0; k1=v1"); this.httpGetUtil.connect(); String result = this.httpGetUtil.readResponse(); assertEquals(HELLO_WORLD_MSG, result); NotifyingListAppender listAppender = (NotifyingListAppender) REQUEST_LOG_IMPL.getAppender("list"); IAccessEvent event = listAppender.list.poll(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS); assertNotNull(event, "No events received"); assertEquals("127.0.0.1", event.getRemoteHost()); assertEquals("localhost", event.getServerName()); assertEquals("/path/foo%20bar;param", event.getRequestURI()); List cookies = event.getCookies(); assertNotNull(cookies); System.out.println("---------------------"); cookies.stream().forEach(System.out::println); System.out.println("---------------------"); assertEquals(2, cookies.size()); for(int i = 0; i < 2 ; i++) { assertEquals("k" + i, cookies.get(i).getName()); assertEquals("v" + i, cookies.get(i).getValue()); } listAppender.list.clear(); } private void close(InputStream inputStream) { if(inputStream != null) { try { inputStream.close(); } catch (IOException e) { throw new RuntimeException(e); } } } @Test public void postContentConverter() throws Exception { URL url = new URL(JETTY_FIXTURE_URL_STR); 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_IN_SECONDS, TimeUnit.SECONDS); assertNotNull(event, "No events received"); // we should test the contents of the requests // assertEquals(msg, event.getRequestContent()); } } JettyFixtureBase.java000066400000000000000000000061441523755721500350600ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/java/ch/qos/logback/access/jetty/** * 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; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandlerCollection; public class JettyFixtureBase { public static String HELLO_WORLD_MSG = "Hello world"; final protected RequestLogImpl requestLogImpl; protected Handler handler = new HelloWorldHandler(HELLO_WORLD_MSG); 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(); ContextHandler context = new ContextHandler("/"); context.setContextPath("/"); context.setHandler(makeHelloWorldHandler(HELLO_WORLD_MSG)); ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection(); contextHandlerCollection.setHandlers(new Handler[] { context }); server.addEventListener(new LCListener()); server.setHandler(contextHandlerCollection); server.start(); } public void stop() throws Exception { server.stop(); server = null; } public void join() throws Exception { server.join(); } protected void configureRequestLogImpl() { requestLogImpl.start(); } protected Handler makeHelloWorldHandler(String msg) { return new HelloWorldHandler(msg); } class HelloWorldHandler extends AbstractHandler { String msg; HelloWorldHandler(String msg) { this.msg = msg; } 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(msg); writer.flush(); baseRequest.setHandled(true); } } } JettyFixtureWithListAndConsoleAppenders.java000066400000000000000000000037161523755721500415670ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/java/ch/qos/logback/access/jetty/** * 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.common.PatternLayoutEncoder; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.common.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(); } public void addEventListener() { server.addEventListener(new LCListener()); } @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); } } LCListener.java000066400000000000000000000015141523755721500336170ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2024, 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 org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.component.LifeCycle.Listener; public class LCListener implements Listener { @Override public void lifeCycleStarted(LifeCycle event) { boolean isStarted = event.isStarted(); System.out.println("isStarted="+isStarted); } } SiftingAppenderTest.java000066400000000000000000000060421523755721500355360ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/java/ch/qos/logback/access/jetty/** * 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.common.sift.SiftingAppender; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.common.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); } } logback-access-v_2.0.15/logback-access-jetty11/src/test/resources/000077500000000000000000000000001523755721500247215ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty11/src/test/resources/logback-asResource.xml000066400000000000000000000005231523755721500311560ustar00rootroot00000000000000 %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-jetty12-blackbox/000077500000000000000000000000001523755721500227255ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/pom.xml000066400000000000000000000066661523755721500242600ustar00rootroot00000000000000 4.0.0 ch.qos.logback.access parent 2.0.15 logback-access-jetty12_blackbox jar Logback Access Jetty 12.0 Blackbox Module Logback Access Jetty 12 Blackbox module org.assertj assertj-core ${assertj-core.version} org.junit.jupiter junit-jupiter-api ${junit-jupiter-api.version} org.junit.jupiter junit-jupiter-engine ${junit-jupiter-api.version} org.hamcrest hamcrest-library ${hamcrest.version} org.junit.jupiter junit-jupiter-params ${junit-jupiter-params.version} ch.qos.logback logback-core compile ch.qos.logback logback-classic ch.qos.logback logback-core ${logback-core.version} test-jar ch.qos.logback.access logback-access-common ch.qos.logback.access logback-access-common ${project.version} test-jar ch.qos.logback.access logback-access-jetty12 ${project.version} org.eclipse.jetty jetty-server ${jetty12.version} org.eclipse.jetty.ee10 jetty-ee10-servlet ${jetty12.version} org.slf4j slf4j-api org.apache.maven.plugins maven-surefire-plugin once plain true logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/000077500000000000000000000000001523755721500235145ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/input/000077500000000000000000000000001523755721500246535ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/input/logback-access-issue-25.xml000066400000000000000000000006471523755721500316170ustar00rootroot00000000000000 BBBBBBBBBBBBB %s %i{a} %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/000077500000000000000000000000001523755721500244735ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/000077500000000000000000000000001523755721500254145ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/000077500000000000000000000000001523755721500260065ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/qos/000077500000000000000000000000001523755721500266105ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/qos/logback/000077500000000000000000000000001523755721500302125ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/qos/logback/access/000077500000000000000000000000001523755721500314535ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/qos/logback/access/jetty12/000077500000000000000000000000001523755721500327555ustar00rootroot00000000000000blackbox/000077500000000000000000000000001523755721500344635ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/qos/logback/access/jetty12BadMessageTest.java000066400000000000000000000043121523755721500401610ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/qos/logback/access/jetty12/blackbox/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.jetty12.blackbox; import java.nio.ByteBuffer; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpTester; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; 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.assertEquals; public class BadMessageTest { private Server server; private LocalConnector connector; @BeforeEach public void startServer() throws Exception { server = new Server(); connector = new LocalConnector(server); server.addConnector(connector); ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); server.setHandler(context); server.start(); } @AfterEach public void stopServer() throws Exception { server.stop(); } @Disabled @Test public void testBadMethod() throws Exception { HttpTester.Request request = HttpTester.newRequest(); request.setMethod("BAD"); // Triggers BadMessageException internally request.setURI("/"); request.setVersion("HTTP/1.1"); request.put(HttpHeader.HOST, "localhost"); request.put(HttpHeader.CONNECTION, "close"); ByteBuffer requestBuffer = request.generate(); ByteBuffer responseBuffer = connector.getResponse(requestBuffer); HttpTester.Response response = HttpTester.parseResponse(responseBuffer); System.out.println(response.getStatus()); assertEquals(400, response.getStatus()); } } FormServlet.java000066400000000000000000000020611523755721500375750ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/qos/logback/access/jetty12/blackbox/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.jetty12.blackbox; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; public class FormServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { req.getParameterNames(); // Throws BadMessageException if form invalid response.setStatus(200); response.getWriter().print("OK"); } } FormServletTest.java000066400000000000000000000073621523755721500404460ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/qos/logback/access/jetty12/blackbox/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.jetty12.blackbox; import ch.qos.logback.access.jetty.RequestLogImpl; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.server.Server; import org.junit.jupiter.api.*; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; public class FormServletTest { static Server server; private URI baseUri; RequestLogImpl requestLogImpl = new RequestLogImpl(); @BeforeEach void startServer() throws Exception { server = new Server(0); configAppenders(requestLogImpl); server.setRequestLog(requestLogImpl); ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); server.setHandler(context); context.addServlet(new ServletHolder(new FormServlet()), "/form"); server.start(); baseUri = server.getURI(); } void configAppenders( RequestLogImpl requestLogImpl) { System.out.println(System.getProperty("user.dir")); requestLogImpl.setFileName("src/input/logback-access-issue-25.xml"); // ConsoleAppender consoleAppender = new ConsoleAppender(); // consoleAppender.setContext(requestLogImpl); // consoleAppender.setName("console"); // PatternLayoutEncoder layout = new PatternLayoutEncoder(); // layout.setContext(requestLogImpl); // layout.setPattern("%date %header{host} %server %clientHost"); // consoleAppender.setEncoder(layout); // layout.start(); // consoleAppender.start(); // // requestLogImpl.addAppender(consoleAppender); } @AfterEach void stopServer() throws Exception { server.stop(); } @Test void testBadForm() throws Exception { HttpClient client = HttpClient.newHttpClient(); byte[] badBytes = new byte[] { (byte) 0xFF }; HttpRequest req = HttpRequest.newBuilder().uri(baseUri.resolve("/form")).header("Content-Type", "application/x-www-form-urlencoded") .POST(HttpRequest.BodyPublishers.ofByteArray(badBytes)).build(); HttpResponse resp = client.send(req, HttpResponse.BodyHandlers.ofString()); assertEquals(400, resp.statusCode()); } @Test void testLargeForm() throws Exception { String largeValue = String.join("", Collections.nCopies(200001, "a")); String body = new StringBuilder("key=").append(largeValue).toString(); byte[] bytes = body.getBytes(StandardCharsets.UTF_8); HttpClient client = HttpClient.newHttpClient(); HttpRequest req = HttpRequest.newBuilder() .uri(baseUri.resolve("/form")) .header("Content-Type", "application/x-www-form-urlencoded") .POST(HttpRequest.BodyPublishers.ofByteArray(bytes)) .build(); HttpResponse resp = client.send(req, HttpResponse.BodyHandlers.ofString()); assertEquals(400, resp.statusCode()); } } Jetty12VersionUtilTest.java000066400000000000000000000017701523755721500416410ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/qos/logback/access/jetty12/blackbox/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.jetty12.blackbox; import ch.qos.logback.access.jetty.Jetty12VersionUtil; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class Jetty12VersionUtilTest { @Test public void smoke() { String jetty12Version = Jetty12VersionUtil.getAccessJetty12VersionBySelfDeclaredProperties(); assertNotNull(jetty12Version); assertTrue(jetty12Version.startsWith("2.0")); } } PostOnlyServlet.java000066400000000000000000000017571523755721500404740ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/qos/logback/access/jetty12/blackbox/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.jetty12.blackbox; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; public class PostOnlyServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { response.setStatus(200); response.getWriter().print("POST handled"); } }PostOnlyServletTest.java000066400000000000000000000044701523755721500413270ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/java/ch/qos/logback/access/jetty12/blackbox/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.jetty12.blackbox; import ch.qos.logback.access.jetty12.blackbox.PostOnlyServlet; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import static org.junit.jupiter.api.Assertions.assertEquals; public class PostOnlyServletTest { private static Server server; private static URI baseUri; @BeforeAll static void startServer() throws Exception { server = new Server(0); ServletContextHandler context = new ServletContextHandler( ); context.setContextPath("/"); server.setHandler(context); context.addServlet(new ServletHolder(new PostOnlyServlet()), "/post"); server.start(); baseUri = server.getURI(); } @AfterAll static void stopServer() throws Exception { server.stop(); } @Test void testPostSuccess() throws Exception { HttpClient client = HttpClient.newHttpClient(); HttpRequest req = HttpRequest.newBuilder().uri(baseUri.resolve("/post")).POST(HttpRequest.BodyPublishers.noBody()).build(); HttpResponse resp = client.send(req, HttpResponse.BodyHandlers.ofString()); assertEquals(200, resp.statusCode()); } @Test void testGetFails() throws Exception { HttpClient client = HttpClient.newHttpClient(); HttpRequest req = HttpRequest.newBuilder().uri(baseUri.resolve("/post")).build(); // GET HttpResponse resp = client.send(req, HttpResponse.BodyHandlers.ofString()); assertEquals(405, resp.statusCode()); } } logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/resources/000077500000000000000000000000001523755721500265055ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12-blackbox/src/test/resources/logback.xml000066400000000000000000000020131523755721500306250ustar00rootroot00000000000000 ABCCCCC %d [%thread] %-5level %logger{36} -%kvp- %msg%n util.thread.QueuedThreadPool logback-access-v_2.0.15/logback-access-jetty12/000077500000000000000000000000001523755721500211425ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/pom.xml000066400000000000000000000050301523755721500224550ustar00rootroot00000000000000 4.0.0 ch.qos.logback.access parent 2.0.15 logback-access-jetty12 jar Logback Access Jetty 12 Module Logback Access Jetty 12 Module ch.qos.logback.access logback-access-common ch.qos.logback.access logback-access-common ${project.version} test-jar test ch.qos.logback logback-core ${logback-core.version} test-jar test org.eclipse.jetty jetty-server ${jetty12.version} src/main/resources true ch/qos/logback/access/jetty/logback-access-jetty12-version.properties org.apache.maven.plugins maven-surefire-plugin once plain true logback-access-v_2.0.15/logback-access-jetty12/src/000077500000000000000000000000001523755721500217315ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/000077500000000000000000000000001523755721500226555ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/000077500000000000000000000000001523755721500235765ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/000077500000000000000000000000001523755721500241705ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/000077500000000000000000000000001523755721500247725ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/000077500000000000000000000000001523755721500263745ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/000077500000000000000000000000001523755721500276355ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/jetty/000077500000000000000000000000001523755721500307745ustar00rootroot00000000000000HeaderUtil.java000066400000000000000000000030611523755721500336060ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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 org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import java.util.Map; import java.util.TreeMap; /** *

A utility class that builds a map from HttpFields (headers).

* *

In case a homonymous header exists, it is merged into the existing value by concatenation.

* * @author Ceki Gülcü * @author Robert Elliot * @since 2.0.7 */ class HeaderUtil { static Map buildHeaderMap(HttpFields headers) { Map requestHeaderMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); for (HttpField httpField : headers) { String existing = requestHeaderMap.get(httpField.getName()); String value = combine(existing, httpField.getValue()); requestHeaderMap.put(httpField.getName(), value); } return requestHeaderMap; } private static String combine(String existing, String field) { if (existing == null) { return field; } else { return existing + "," + field; } } } Jetty12Constants.java000066400000000000000000000011631523755721500347200ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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; public class Jetty12Constants { static String LOGBACK_ACCESS_JETTY12_MODULE_NAME = "logback-access-jetty12"; } Jetty12VersionUtil.java000066400000000000000000000027771523755721500352430ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.InputStream; import java.util.Properties; import static ch.qos.logback.access.jetty.Jetty12Constants.LOGBACK_ACCESS_JETTY12_MODULE_NAME; public class Jetty12VersionUtil { static String LOGBACK_ACCESS_JETTY12_MODULE_VERSION_PROPERTIES_FILE = LOGBACK_ACCESS_JETTY12_MODULE_NAME + "-version.properties"; static String LOGBACK_ACCESS_JETTY12_MODULE_VERSION_PROPERTY_KEY = LOGBACK_ACCESS_JETTY12_MODULE_NAME + "-version"; static public String getAccessJetty12VersionBySelfDeclaredProperties() { Properties props = new Properties(); try (InputStream is = Jetty12Constants.class.getResourceAsStream(LOGBACK_ACCESS_JETTY12_MODULE_VERSION_PROPERTIES_FILE)) { if (is != null) { props.load(is); return props.getProperty(LOGBACK_ACCESS_JETTY12_MODULE_VERSION_PROPERTY_KEY); } else { return null; } } catch (IOException e) { return null; } } } JettyModernServerAdapter.java000066400000000000000000000040251523755721500365150ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.spi.ServerAdapter; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; 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.getContentBytesWritten(response); //return response.getHttpChannel().getBytesWritten(); } @Override public int getStatusCode() { return response.getStatus(); //return response.getCommittedMetaData().getStatus(); } @Override public long getRequestTimestamp() { return Request.getTimeStamp(request); } @Override public Map buildResponseHeaderMap() { Map responseHeaderMap = new HashMap<>(); HttpFields.Mutable httpFields = response.getHeaders(); for(HttpField field: httpFields) { String key = field.getName(); String value = field.getValue(); responseHeaderMap.put(key, value); } return responseHeaderMap; } } JettyServerAdapter.java000066400000000000000000000031001523755721500353410ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.spi.ServerAdapter; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Response; import java.util.Map; import static ch.qos.logback.access.jetty.HeaderUtil.buildHeaderMap; /** * 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.getContentBytesWritten(response); } @Override public int getStatusCode() { return response.getStatus(); } @Override public long getRequestTimestamp() { return Request.getTimeStamp(request); } @Override public Map buildResponseHeaderMap() { return buildHeaderMap(response.getHeaders()); } } RequestLogImpl.java000066400000000000000000000447371523755721500345130ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.AccessConstants; import ch.qos.logback.access.common.joran.JoranConfigurator; import ch.qos.logback.access.common.spi.AccessEvent; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.common.util.AccessCommonVersionUtil; 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.status.WarnStatus; import ch.qos.logback.core.util.CoreVersionUtil; import ch.qos.logback.core.util.FileUtil; import ch.qos.logback.core.util.OptionHelper; import ch.qos.logback.core.util.StatusPrinter; import ch.qos.logback.core.util.VersionUtil; 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; 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 static ch.qos.logback.core.CoreConstants.DEFAULT_CONTEXT_NAME; /** * 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() { setName(DEFAULT_CONTEXT_NAME); putObject(CoreConstants.EVALUATOR_MAP, new HashMap>()); } @Override public void log(Request jettyRequest, Response jettyResponse) { JettyServerAdapter adapter = makeJettyServerAdapter(jettyRequest, jettyResponse); RequestWrapper requestWrapper = new RequestWrapper(jettyRequest); ResponseWrapper responseWrapper = new ResponseWrapper(jettyResponse); IAccessEvent accessEvent = new AccessEvent(this, requestWrapper, responseWrapper, 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)); } protected void addWarn(String msg) { getStatusManager().add(new WarnStatus(msg, this)); } private void addError(String msg) { getStatusManager().add(new ErrorStatus(msg, this)); } @Override public void start() { state = State.STARTING; versionCheck(); try { configure(); if (!isQuiet()) { StatusPrinter.print(getStatusManager()); } state = State.STARTED; } catch (Throwable t) { t.printStackTrace(); state = State.FAILED; } } static String LOGBACK_ACCESS_JETTY12_NAME = "logback-access-jetty12"; static String LOGBACK_ACCESS_COMMON_NAME = "logback-access-common"; static String LOGBACK_CORE_NAME = "logback-core"; private void versionCheck() { try { String coreVersion = CoreVersionUtil.getCoreVersionBySelfDeclaredProperties(); String accessCommonVersion = AccessCommonVersionUtil.getAccessCommonVersionBySelfDeclaredProperties(); String accessJetty12Version = Jetty12VersionUtil.getAccessJetty12VersionBySelfDeclaredProperties(); VersionUtil.checkForVersionEquality(this, accessJetty12Version, accessCommonVersion, LOGBACK_ACCESS_JETTY12_NAME, LOGBACK_ACCESS_COMMON_NAME); AccessCommonVersionUtil accessCommonVersionUtil = new AccessCommonVersionUtil(this); accessCommonVersionUtil.compareExpectedAndFoundVersion( coreVersion, AccessConstants.class, accessCommonVersion, LOGBACK_ACCESS_COMMON_NAME, LOGBACK_CORE_NAME); } catch(NoClassDefFoundError e) { addWarn("Missing ch.logback.core.util.VersionUtil class on classpath. The version of logback-core is probably earlier than 1.5.25."); } catch(NoSuchMethodError e) { addWarn(e.getMessage() + ". The version of logback-core is probably earlier than 1.5.26."); } } 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 } } RequestLogRegistry.java000066400000000000000000000017341523755721500354100ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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); } } RequestWrapper.java000066400000000000000000000252471523755721500345630ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.spi.WrappedHttpRequest; import jakarta.servlet.AsyncContext; import jakarta.servlet.DispatcherType; import jakarta.servlet.RequestDispatcher; import jakarta.servlet.ServletConnection; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.ServletInputStream; import jakarta.servlet.ServletRequest; import jakarta.servlet.ServletResponse; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpUpgradeHandler; import jakarta.servlet.http.Part; import org.eclipse.jetty.http.HttpCookie; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Session; import org.eclipse.jetty.util.Fields; import java.io.BufferedReader; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.Principal; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import static ch.qos.logback.access.common.spi.IAccessEvent.NA; import static ch.qos.logback.access.jetty.HeaderUtil.buildHeaderMap; import static java.nio.charset.StandardCharsets.UTF_8; public class RequestWrapper implements HttpServletRequest, WrappedHttpRequest { static final Cookie[] EMPTY_COOKIE_ARRAY = new Cookie[0]; static final String[] EMPTY_STRING_ARRAY = new String[0]; Request request; StringBuffer requestURL; public RequestWrapper(Request request) { this.request = request; } @Override public String getAuthType() { return null; } @Override public Cookie[] getCookies() { List httpCookies = Request.getCookies(request); List cookieList = httpCookies.stream().map(httpCookie -> new Cookie(httpCookie.getName(), httpCookie.getValue())).collect( Collectors.toList()); return cookieList.toArray(EMPTY_COOKIE_ARRAY); } @Override public long getDateHeader(String name) { return 0; } @Override public String getHeader(String name) { return null; } @Override public Enumeration getHeaders(String name) { return null; } @Override public Enumeration getHeaderNames() { return null; } @Override public Map buildRequestHeaderMap() { return buildHeaderMap(request.getHeaders()); } @Override public int getIntHeader(String name) { return 0; } @Override public String getMethod() { return request.getMethod(); } @Override public String getPathInfo() { return null; } @Override public String getPathTranslated() { return null; } @Override public String getContextPath() { return null; } @Override public String getQueryString() { return request.getHttpURI().getQuery(); } @Override public String getRemoteUser() { return null; } @Override public boolean isUserInRole(String role) { return false; } @Override public Principal getUserPrincipal() { return null; } @Override public String getRequestedSessionId() { return null; } @Override public String getRequestURI() { return request.getHttpURI().getPath(); } @Override public StringBuffer getRequestURL() { if (requestURL == null) { String result = request.getHttpURI().asString(); requestURL = new StringBuffer(result); } return requestURL; } @Override public String getServletPath() { return null; } @Override public String getSessionID() { Session session = request.getSession(false); if (session == null) { return NA; } else { return session.getId(); } } @Override public HttpSession getSession(boolean create) { throw new UnsupportedOperationException(); } @Override public HttpSession getSession() { throw new UnsupportedOperationException(); } @Override public String changeSessionId() { throw new UnsupportedOperationException(); } @Override public boolean isRequestedSessionIdValid() { throw new UnsupportedOperationException(); } @Override public boolean isRequestedSessionIdFromCookie() { return false; } @Override public boolean isRequestedSessionIdFromURL() { throw new UnsupportedOperationException(); } @Override public boolean authenticate(HttpServletResponse response) throws IOException, ServletException { return false; } @Override public void login(String username, String password) throws ServletException { } @Override public void logout() throws ServletException { } @Override public Collection getParts() throws IOException, ServletException { return null; } @Override public Part getPart(String name) throws IOException, ServletException { return null; } @Override public T upgrade(Class handlerClass) throws IOException, ServletException { return null; } @Override public Object getAttribute(String name) { return request.getAttribute(name); } @Override public Enumeration getAttributeNames() { Set attributeNamesSet = request.getAttributeNameSet(); return Collections.enumeration(attributeNamesSet); } @Override public String getCharacterEncoding() { return null; } @Override public void setCharacterEncoding(String env) throws UnsupportedEncodingException { } @Override public int getContentLength() { return 0; } @Override public long getContentLengthLong() { return 0; } @Override public String getContentType() { return null; } @Override public ServletInputStream getInputStream() throws IOException { return null; } @Override public Map buildRequestParameterMap() { Map results = new HashMap<>(); Fields allParameters = Request.extractQueryParameters(request, UTF_8); for (Fields.Field field : allParameters) { results.put(field.getName(), field.getValues().toArray(EMPTY_STRING_ARRAY)); } return results; } @Override public String getParameter(String name) { throw new UnsupportedOperationException(); } @Override public Enumeration getParameterNames() { throw new UnsupportedOperationException(); } @Override public String[] getParameterValues(String name) { throw new UnsupportedOperationException(); } @Override public Map getParameterMap() { throw new UnsupportedOperationException(); } @Override public String getProtocol() { return request.getConnectionMetaData().getProtocol(); } @Override public String getScheme() { return request.getHttpURI().getScheme(); } @Override public String getServerName() { return Request.getServerName(request); } @Override public int getServerPort() { return Request.getServerPort(request); } @Override public BufferedReader getReader() throws IOException { return null; } @Override public String getRemoteAddr() { return Request.getRemoteAddr(request); } @Override public String getRemoteHost() { return Request.getRemoteAddr(request); } @Override public void setAttribute(String name, Object o) { } @Override public void removeAttribute(String name) { } @Override public Locale getLocale() { return Request.getLocales(request).get(0); } @Override public Enumeration getLocales() { return Collections.enumeration(Request.getLocales(request)); } @Override public boolean isSecure() { return HttpScheme.HTTPS.is(request.getHttpURI().getScheme()); } @Override public RequestDispatcher getRequestDispatcher(String path) { return null; } @Override public int getRemotePort() { return Request.getRemotePort(request); } @Override public String getLocalName() { return null; } @Override public String getLocalAddr() { return Request.getLocalAddr(request); } @Override public int getLocalPort() { return Request.getLocalPort(request); } @Override public ServletContext getServletContext() { return null; } @Override public AsyncContext startAsync() throws IllegalStateException { return null; } @Override public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException { return null; } @Override public boolean isAsyncStarted() { return false; } @Override public boolean isAsyncSupported() { return false; } @Override public AsyncContext getAsyncContext() { return null; } @Override public DispatcherType getDispatcherType() { return null; } @Override public String getRequestId() { return request.getConnectionMetaData().getId() + "#" + request.getId(); } @Override public String getProtocolRequestId() { HttpVersion httpVersion = request.getConnectionMetaData().getHttpVersion(); if(httpVersion == HttpVersion.HTTP_2 || httpVersion == (HttpVersion.HTTP_3)) { return request.getId(); } else { return NA; } } @Override public ServletConnection getServletConnection() { return null; } } ResponseWrapper.java000066400000000000000000000070241523755721500347220ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/jetty/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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 jakarta.servlet.ServletOutputStream; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.server.Response; import java.io.IOException; import java.io.PrintWriter; import java.util.Collection; import java.util.Locale; public class ResponseWrapper implements HttpServletResponse { Response response; public ResponseWrapper(Response response) { this.response = response; } @Override public void addCookie(Cookie cookie) { } @Override public boolean containsHeader(String name) { return false; } @Override public String encodeURL(String url) { return null; } @Override public String encodeRedirectURL(String url) { return null; } @Override public void sendError(int sc, String msg) throws IOException { } @Override public void sendError(int sc) throws IOException { } @Override public void sendRedirect(String location) throws IOException { } @Override public void setDateHeader(String name, long date) { } @Override public void addDateHeader(String name, long date) { } @Override public void setHeader(String name, String value) { } @Override public void addHeader(String name, String value) { } @Override public void setIntHeader(String name, int value) { } @Override public void addIntHeader(String name, int value) { } @Override public void setStatus(int sc) { } @Override public int getStatus() { return 0; } @Override public String getHeader(String name) { return null; } @Override public Collection getHeaders(String name) { return null; } @Override public Collection getHeaderNames() { return null; } @Override public String getCharacterEncoding() { return null; } @Override public String getContentType() { return null; } @Override public ServletOutputStream getOutputStream() throws IOException { return null; } @Override public PrintWriter getWriter() throws IOException { return null; } @Override public void setCharacterEncoding(String charset) { } @Override public void setContentLength(int len) { } @Override public void setContentLengthLong(long len) { } @Override public void setContentType(String type) { } @Override public void setBufferSize(int size) { } @Override public int getBufferSize() { return 0; } @Override public void flushBuffer() throws IOException { } @Override public void resetBuffer() { } @Override public boolean isCommitted() { return false; } @Override public void reset() { } @Override public void setLocale(Locale loc) { } @Override public Locale getLocale() { return null; } } package.html000066400000000000000000000012521523755721500331760ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/java/ch/qos/logback/access/jetty

This is logback access' implementation for Jetty 8.

logback-access-v_2.0.15/logback-access-jetty12/src/main/java/module-info.java000066400000000000000000000004371523755721500266630ustar00rootroot00000000000000module ch.qos.logback.access.jetty { requires ch.qos.logback.core; requires ch.qos.logback.access.common; requires org.eclipse.jetty.server; // servlet api requires jakarta.servlet; requires org.eclipse.jetty.http; exports ch.qos.logback.access.jetty; } logback-access-v_2.0.15/logback-access-jetty12/src/main/resources/000077500000000000000000000000001523755721500246675ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/resources/ch/000077500000000000000000000000001523755721500252615ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/resources/ch/qos/000077500000000000000000000000001523755721500260635ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/resources/ch/qos/logback/000077500000000000000000000000001523755721500274655ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/resources/ch/qos/logback/access/000077500000000000000000000000001523755721500307265ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/resources/ch/qos/logback/access/jetty/000077500000000000000000000000001523755721500320655ustar00rootroot00000000000000logback-access-jetty12-version.properties000066400000000000000000000007741523755721500417600ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/main/resources/ch/qos/logback/access/jetty# # Logback: the reliable, generic, fast and flexible logging framework. # Copyright (C) 1999-2026, QOS.ch. All rights reserved. # # This program and the accompanying materials are dual-licensed under # either the terms of the Eclipse Public License v2.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. # logback-access-jetty12-version=${project.version}logback-access-v_2.0.15/logback-access-jetty12/src/test/000077500000000000000000000000001523755721500227105ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/input/000077500000000000000000000000001523755721500240475ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/input/jetty/000077500000000000000000000000001523755721500252065ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/input/jetty/sifting.xml000066400000000000000000000006371523755721500274010ustar00rootroot00000000000000 uri REQUEST_URI NA logback-access-v_2.0.15/logback-access-jetty12/src/test/input/joran/000077500000000000000000000000001523755721500251605ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/input/joran/conditional/000077500000000000000000000000001523755721500274635ustar00rootroot00000000000000conditionalConsole.xml000066400000000000000000000005361523755721500337600ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/input/joran/conditional %h %l %u %user %date "%r" %s %b conditionalConsole_ELSE.xml000066400000000000000000000007371523755721500345730ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/input/joran/conditional %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-jetty12/src/test/input/joran/defaultLayout.xml000066400000000000000000000005361523755721500305300ustar00rootroot00000000000000 %requestMethod logback-access-v_2.0.15/logback-access-jetty12/src/test/input/joran/smoke.xml000066400000000000000000000002101523755721500270110ustar00rootroot00000000000000 logback-access-v_2.0.15/logback-access-jetty12/src/test/input/joran/tomcat/000077500000000000000000000000001523755721500264475ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/input/joran/tomcat/logback-access.xml000066400000000000000000000005231523755721500320320ustar00rootroot00000000000000 %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-jetty12/src/test/java/000077500000000000000000000000001523755721500236315ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/java/ch/000077500000000000000000000000001523755721500242235ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/java/ch/qos/000077500000000000000000000000001523755721500250255ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/java/ch/qos/logback/000077500000000000000000000000001523755721500264275ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/java/ch/qos/logback/access/000077500000000000000000000000001523755721500276705ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/java/ch/qos/logback/access/jetty/000077500000000000000000000000001523755721500310275ustar00rootroot00000000000000Jetty12BasicTest.java000066400000000000000000000124521523755721500346630ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/java/ch/qos/logback/access/jetty/** * 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.common.testUtil.HttpGetUtil; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.common.spi.Util; import ch.qos.logback.access.common.testUtil.NotifyingListAppender; import ch.qos.logback.core.testUtil.RandomUtil; import jakarta.servlet.http.Cookie; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.HttpURLConnection; import java.net.URL; import java.util.List; import java.util.concurrent.TimeUnit; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; public class Jetty12BasicTest { private static final int TIMEOUT = 5; RequestLogImpl REQUEST_LOG_IMPL = new RequestLogImpl(); JettyFixtureWithListAndConsoleAppenders JETTY_FIXTURE; String JETTY_FIXTURE_URL_STR; int RANDOM_SERVER_PORT = RandomUtil.getRandomServerPort(); HttpGetUtil httpGetUtil; @BeforeEach public void startServer() throws Exception { REQUEST_LOG_IMPL = new RequestLogImpl(); JETTY_FIXTURE = new JettyFixtureWithListAndConsoleAppenders(REQUEST_LOG_IMPL, RANDOM_SERVER_PORT); JETTY_FIXTURE.start(); JETTY_FIXTURE_URL_STR = JETTY_FIXTURE.getUrl(); } @AfterEach public void stopServer() throws Exception { if(this.httpGetUtil != null) { this.httpGetUtil.disconnect(); } 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 { HttpGetUtil httpGetUtil = new HttpGetUtil(JETTY_FIXTURE_URL_STR + "path/foo%20bar;param?query#fragment"); httpGetUtil = httpGetUtil.init().addCookie("k0=v0").addCookie("k1=v1"); httpGetUtil.connect(); String result = httpGetUtil.readResponse(); 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()); assertEquals("/path/foo%20bar;param", event.getRequestURI()); List cookies = event.getCookies(); assertNotNull(cookies); assertEquals(2, cookies.size()); for(int i = 0; i < 2 ; i++) { assertEquals("k" + i, cookies.get(i).getName()); assertEquals("v" + i, cookies.get(i).getValue()); } listAppender.list.clear(); httpGetUtil.disconnect(); } private void close(InputStream inputStream) { if(inputStream != null) { try { inputStream.close(); } catch (IOException e) { throw new RuntimeException(e); } } } @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()); } } JettyFixtureBase.java000066400000000000000000000047001523755721500350550ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/java/ch/qos/logback/access/jetty/** * 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.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Response; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.util.Callback; 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 { @Override public boolean handle(Request request, Response response, Callback callback) throws Exception { HttpFields.Mutable responseHeaders = response.getHeaders(); responseHeaders.put(HttpHeader.CONTENT_TYPE, "text/plain; charset=UTF-8"); byte[] bytes = "hello world".getBytes(StandardCharsets.UTF_8); ByteBuffer content = ByteBuffer.wrap(bytes); response.write(true, content, callback); return true; } } } JettyFixtureWithListAndConsoleAppenders.java000066400000000000000000000036121523755721500415630ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/java/ch/qos/logback/access/jetty/** * 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.common.PatternLayoutEncoder; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.common.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); } } SiftingAppenderTest.java000066400000000000000000000061211523755721500355350ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/java/ch/qos/logback/access/jetty/** * 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.common.sift.SiftingAppender; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.common.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() { 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(); String prefix = "http://localhost:"+RANDOM_SERVER_PORT+"/"; 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); } } logback-access-v_2.0.15/logback-access-jetty12/src/test/resources/000077500000000000000000000000001523755721500247225ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-jetty12/src/test/resources/logback-asResource.xml000066400000000000000000000005231523755721500311570ustar00rootroot00000000000000 %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-tomcat/000077500000000000000000000000001523755721500211275ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/pom.xml000066400000000000000000000065661523755721500224610ustar00rootroot00000000000000 4.0.0 ch.qos.logback.access parent 2.0.15 logback-access-tomcat jar Logback Access Tomcat Module Logback Access Tomcat Module module org.junit.jupiter junit-jupiter-params ${junit-jupiter-params.version} test ch.qos.logback logback-core ch.qos.logback logback-core ${logback-core.version} test-jar test ch.qos.logback.access logback-access-common ch.qos.logback.access logback-access-common ${project.version} test-jar test org.apache.tomcat tomcat-catalina ${tomcat_10_1.version} provided org.apache.tomcat tomcat-coyote ${tomcat_10_1.version} provided src/main/resources true ch/qos/logback/access/tomcat/logback-access-tomcat-version.properties org.apache.maven.plugins maven-surefire-plugin once plain true **/AllAccessTest.java **/PackageTest.java **/SerializationPerfTest.java logback-access-v_2.0.15/logback-access-tomcat/src/000077500000000000000000000000001523755721500217165ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/000077500000000000000000000000001523755721500226425ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/java/000077500000000000000000000000001523755721500235635ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/java/ch/000077500000000000000000000000001523755721500241555ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/java/ch/qos/000077500000000000000000000000001523755721500247575ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/java/ch/qos/logback/000077500000000000000000000000001523755721500263615ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/java/ch/qos/logback/access/000077500000000000000000000000001523755721500276225ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/java/ch/qos/logback/access/tomcat/000077500000000000000000000000001523755721500311115ustar00rootroot00000000000000AccessTomcatConstants.java000066400000000000000000000011701523755721500361420ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/java/ch/qos/logback/access/tomcat/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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; public class AccessTomcatConstants { static String LOGBACK_ACCESS_TOMCAT_MODULE_NAME = "logback-access-tomcat"; } AccessTomcatVersionUtil.java000066400000000000000000000041011523755721500364460ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/java/ch/qos/logback/access/tomcat/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.core.CoreConstants; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import static ch.qos.logback.access.tomcat.AccessTomcatConstants.LOGBACK_ACCESS_TOMCAT_MODULE_NAME; public class AccessTomcatVersionUtil { static String LOGBACK_ACCESS_TOMCAT_MODULE_VERSION_PROPERTIES_FILE = LOGBACK_ACCESS_TOMCAT_MODULE_NAME + "-version.properties"; static String LOGBACK_ACCESS_TOMCAT_MODULE_VERSION_PROPERTY_KEY = LOGBACK_ACCESS_TOMCAT_MODULE_NAME + "-version"; /** * Retrieves the version of the "logback-core" module using a properties file * associated with the module. * *

The method locates and reads a properties file named "logback-core-version.properties" * in the package of the {@code CoreConstants.class}. It then extracts the version * information using the key "logback-core-version". *

* * @return the version of the "logback-core" module as a string, or null if the version cannot be determined * @since 1.5.26 */ static public String getCoreVersionBySelfDeclaredProperties() { Properties props = new Properties(); try (InputStream is = AccessTomcatConstants.class.getResourceAsStream(LOGBACK_ACCESS_TOMCAT_MODULE_VERSION_PROPERTIES_FILE)) { if (is != null) { props.load(is); return props.getProperty(LOGBACK_ACCESS_TOMCAT_MODULE_VERSION_PROPERTY_KEY); } else { return null; } } catch (IOException e) { return null; } } } LogbackValve.java000066400000000000000000000414231523755721500342410ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/java/ch/qos/logback/access/tomcat/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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 java.util.concurrent.locks.ReentrantLock; import ch.qos.logback.access.common.AccessConstants; import ch.qos.logback.access.common.joran.JoranConfigurator; import ch.qos.logback.access.common.spi.AccessEvent; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.common.util.AccessCommonVersionUtil; import ch.qos.logback.core.spi.ConfigurationEvent; import ch.qos.logback.core.spi.ConfigurationEventListener; import ch.qos.logback.core.util.CoreVersionUtil; import ch.qos.logback.core.util.VersionUtil; 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.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 static ch.qos.logback.access.tomcat.AccessTomcatConstants.LOGBACK_ACCESS_TOMCAT_MODULE_NAME; //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(); ReentrantLock configurationLock = new ReentrantLock(); 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 { versionCheck(); 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); } static String LOGBACK_ACCESS_COMMON_NAME = "logback-access-common"; static String LOGBACK_CORE_NAME = "logback-core"; private void versionCheck() { try { String coreVersion = CoreVersionUtil.getCoreVersionBySelfDeclaredProperties(); String accessCommonVersion = AccessCommonVersionUtil.getAccessCommonVersionBySelfDeclaredProperties(); String tomcatVersion = AccessTomcatVersionUtil.getCoreVersionBySelfDeclaredProperties(); VersionUtil.checkForVersionEquality(this, tomcatVersion, accessCommonVersion, LOGBACK_ACCESS_TOMCAT_MODULE_NAME, LOGBACK_ACCESS_COMMON_NAME); AccessCommonVersionUtil accessCommonVersionUtil = new AccessCommonVersionUtil(this); accessCommonVersionUtil.compareExpectedAndFoundVersion(coreVersion, AccessConstants.class, accessCommonVersion, LOGBACK_ACCESS_COMMON_NAME, LOGBACK_CORE_NAME); } catch(NoClassDefFoundError e) { addWarn("Missing ch.logback.core.util.VersionUtil class on classpath. The version of logback-core is probably earlier than 1.5.25."); } catch(NoSuchMethodError e) { addWarn(e.getMessage() + ". The version of logback-core is probably earlier than 1.5.26."); } } 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 addSubstitutionProperty(String key, String value) { this.propertyMap.put(key, value); } @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 ReentrantLock 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)); } } TomcatServerAdapter.java000066400000000000000000000033551523755721500356220ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/java/ch/qos/logback/access/tomcat/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.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; } } package.html000066400000000000000000000012511523755721500333120ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/java/ch/qos/logback/access/tomcat

This is logback access' implementation for Tomcat.

logback-access-v_2.0.15/logback-access-tomcat/src/main/java/module-info.java000066400000000000000000000003531523755721500266450ustar00rootroot00000000000000module ch.qos.logback.access.tomcat { requires ch.qos.logback.core; requires ch.qos.logback.access.common; requires org.apache.tomcat.coyote; requires org.apache.tomcat.catalina; exports ch.qos.logback.access.tomcat; } logback-access-v_2.0.15/logback-access-tomcat/src/main/resources/000077500000000000000000000000001523755721500246545ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/resources/ch/000077500000000000000000000000001523755721500252465ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/resources/ch/qos/000077500000000000000000000000001523755721500260505ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/resources/ch/qos/logback/000077500000000000000000000000001523755721500274525ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/resources/ch/qos/logback/access/000077500000000000000000000000001523755721500307135ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/resources/ch/qos/logback/access/tomcat/000077500000000000000000000000001523755721500322025ustar00rootroot00000000000000logback-access-tomcat-version.properties000066400000000000000000000000601523755721500420460ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/main/resources/ch/qos/logback/access/tomcatlogback-access-tomcat-version=${project.version}logback-access-v_2.0.15/logback-access-tomcat/src/test/000077500000000000000000000000001523755721500226755ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/000077500000000000000000000000001523755721500240345ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/integration/000077500000000000000000000000001523755721500263575ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/integration/db/000077500000000000000000000000001523755721500267445ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/integration/db/mysql-with-driver.xml000066400000000000000000000006661523755721500331050ustar00rootroot00000000000000 com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/logback root oracle10g-with-driver.xml000066400000000000000000000006711523755721500334320ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/integration/db oracle.jdbc.OracleDriver jdbc:oracle:thin:@localhost:1522:xe hr hr oracle11g-with-driver.xml000066400000000000000000000007021523755721500334260ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/integration/db oracle.jdbc.OracleDriver jdbc:oracle:thin:@localhost:1521:orcl SCOTT SCOTT postgresql-with-driver.xml000066400000000000000000000007261523755721500340610ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/integration/db org.postgresql.Driver jdbc:postgresql://192.168.1.5:5432/test logback logback sqlserver-with-driver.xml000066400000000000000000000007521523755721500337030ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/integration/db com.microsoft.sqlserver.jdbc.SQLServerDriver jdbc:sqlserver://localhost:1987;databaseName=logback; logback logback logback-access-v_2.0.15/logback-access-tomcat/src/test/input/joran/000077500000000000000000000000001523755721500251455ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/joran/conditional/000077500000000000000000000000001523755721500274505ustar00rootroot00000000000000conditionalConsole.xml000066400000000000000000000005361523755721500337450ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/joran/conditional %h %l %u %user %date "%r" %s %b conditionalConsole_ELSE.xml000066400000000000000000000007371523755721500345600ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/joran/conditional %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-tomcat/src/test/input/joran/defaultLayout.xml000066400000000000000000000005361523755721500305150ustar00rootroot00000000000000 %requestMethod logback-access-v_2.0.15/logback-access-tomcat/src/test/input/joran/smoke.xml000066400000000000000000000002101523755721500267760ustar00rootroot00000000000000 logback-access-v_2.0.15/logback-access-tomcat/src/test/input/joran/tomcat/000077500000000000000000000000001523755721500264345ustar00rootroot00000000000000logback-access-included.xml000066400000000000000000000011411523755721500335220ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/joran/tomcat logback-access-including.xml000066400000000000000000000016001523755721500337070ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/input/joran/tomcat %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-tomcat/src/test/input/joran/tomcat/logback-access.xml000066400000000000000000000005231523755721500320170ustar00rootroot00000000000000 %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-tomcat/src/test/java/000077500000000000000000000000001523755721500236165ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/java/ch/000077500000000000000000000000001523755721500242105ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/java/ch/qos/000077500000000000000000000000001523755721500250125ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/java/ch/qos/logback/000077500000000000000000000000001523755721500264145ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/java/ch/qos/logback/access/000077500000000000000000000000001523755721500276555ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/java/ch/qos/logback/access/tomcat/000077500000000000000000000000001523755721500311445ustar00rootroot00000000000000ListAppender.java000066400000000000000000000015721523755721500343270ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/java/ch/qos/logback/access/tomcat/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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.common.spi.IAccessEvent; import ch.qos.logback.core.AppenderBase; import java.util.ArrayList; import java.util.List; public class ListAppender extends AppenderBase { public List list = new ArrayList<>(); @Override protected void append(IAccessEvent eventObject) { list.add(eventObject); } } LogbackValveTest.java000066400000000000000000000115651523755721500351400ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/java/ch/qos/logback/access/tomcat/** * 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.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.assertEquals; 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, TomcatTestContants.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 fileUnderCatalinaBaseWithInclusionsShouldBeFound() throws LifecycleException { System.setProperty(LogbackValve.CATALINA_BASE_KEY, TomcatTestContants.JORAN_INPUT_PREFIX + "tomcat/"); final String fileName = "logback-access-including.xml"; setupValve(fileName); valve.start(); assertEquals("value_of_var_tomcat_inclusion", System.getProperty("var_tomcat_inclusion")); checker.assertContainsMatch("Found configuration file"); checker.assertContainsMatch("Done configuring"); checker.assertIsErrorFree(); } @Test public void nonExistingConfigFileUnderCatalinaBaseShouldResultInWarning() throws LifecycleException { final String path = TomcatTestContants.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, TomcatTestContants.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()); } @Test public void inclusion() throws LifecycleException { final String fileName = "inclusion/logback-top.xml"; setupValve(fileName); valve.start(); checker.assertContainsMatch("Processing appender named \\[LIST\\]"); checker.assertContainsMatch("Attaching appender named \\[LIST\\]"); checker.assertIsWarningOrErrorFree(); } private void setupValve(final String resourceName) { valve.setFilename(resourceName); valve.setName("test"); valve.setContainer(new ContainerBase() { @Override protected String getObjectNameKeyProperties() { return "getObjectNameKeyProperties-test"; } }); } }TomcatTestContants.java000066400000000000000000000013611523755721500355320ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/java/ch/qos/logback/access/tomcat/** * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2024, 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; public class TomcatTestContants { 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/"; } logback-access-v_2.0.15/logback-access-tomcat/src/test/resources/000077500000000000000000000000001523755721500247075ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/resources/inclusion/000077500000000000000000000000001523755721500267125ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/resources/inclusion/logback-included-list.xml000066400000000000000000000011631523755721500335750ustar00rootroot00000000000000 logback-included-stdout.xml000066400000000000000000000013421523755721500340640ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat/src/test/resources/inclusion %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-tomcat/src/test/resources/inclusion/logback-top.xml000066400000000000000000000014351523755721500316410ustar00rootroot00000000000000 logback-access-v_2.0.15/logback-access-tomcat/src/test/resources/logback-asResource.xml000066400000000000000000000005231523755721500311440ustar00rootroot00000000000000 %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/000077500000000000000000000000001523755721500235145ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/pom.xml000066400000000000000000000067001523755721500250340ustar00rootroot00000000000000 4.0.0 ch.qos.logback.access parent 2.0.15 logback-access-tomcat_10_1_blackbox jar Logback Access Tomcat 10.1 Blackbox Module Logback Access Tomcat 10.1 Blackbox module org.assertj assertj-core ${assertj-core.version} org.junit.jupiter junit-jupiter-api ${junit-jupiter-api.version} org.junit.jupiter junit-jupiter-engine ${junit-jupiter-api.version} org.hamcrest hamcrest-library ${hamcrest.version} org.junit.jupiter junit-jupiter-params ${junit-jupiter-params.version} ch.qos.logback logback-core compile ch.qos.logback logback-classic ch.qos.logback logback-core ${logback-core.version} test-jar ch.qos.logback.access logback-access-common ch.qos.logback.access logback-access-common ${project.version} test-jar ch.qos.logback.access logback-access-tomcat ${project.version} org.apache.tomcat tomcat-catalina ${tomcat_10_1.version} org.apache.tomcat tomcat-coyote ${tomcat_10_1.version} org.slf4j slf4j-api org.apache.maven.plugins maven-surefire-plugin once plain true logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/000077500000000000000000000000001523755721500243035ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/000077500000000000000000000000001523755721500252625ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/java/000077500000000000000000000000001523755721500262035ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/java/ch/000077500000000000000000000000001523755721500265755ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/java/ch/qos/000077500000000000000000000000001523755721500273775ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/java/ch/qos/logback/000077500000000000000000000000001523755721500310015ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/java/ch/qos/logback/access/000077500000000000000000000000001523755721500322425ustar00rootroot00000000000000tomcat_10_1/000077500000000000000000000000001523755721500341725ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/java/ch/qos/logback/accessEmbeddedTomcatTest.java000066400000000000000000000104611523755721500405400ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/java/ch/qos/logback/access/tomcat_10_1/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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_10_1; import ch.qos.logback.access.common.testUtil.HttpGetUtil; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.tomcat.LogbackValve; import ch.qos.logback.core.testUtil.RandomUtil; import jakarta.servlet.http.Cookie; import org.apache.catalina.Context; import org.apache.catalina.LifecycleException; import org.apache.catalina.connector.Connector; import org.apache.catalina.startup.Tomcat; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.File; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; public class EmbeddedTomcatTest { Tomcat tomcat; int port; LogbackValve logbackValve; String text = "

Welcome

"; @BeforeEach public void embed() throws LifecycleException { this.tomcat = new Tomcat(); this.port = RandomUtil.getRandomServerPort();; this.logbackValve = new LogbackValve(); tomcat.setBaseDir("/tmp"); //tomcat.setPort(port); Connector connector = tomcat.getConnector(); connector.setPort(port); tomcat.setConnector(connector);//getService().addConnector(connector); String contextPath = ""; String docBase = new File(".").getAbsolutePath(); Context context = tomcat.addContext(contextPath, docBase); String servletName = "SampleServlet"; String urlPattern = "/*"; setupValve("logback-stdout.xml"); //logbackValve.setContainer(context); context.getPipeline().addValve(logbackValve); tomcat.addServlet(contextPath, servletName, new SampleServlet(text)); context.addServletMappingDecoded(urlPattern, servletName); tomcat.start(); } private void setupValve(String fileName) { logbackValve.setFilename(fileName); logbackValve.setName("test"); } @AfterEach public void tearDown() throws LifecycleException, InterruptedException { tomcat.stop(); } @Test public void smoke() throws MalformedURLException, InterruptedException { String uri = "/moo"; HttpGetUtil hgu = new HttpGetUtil("http://127.0.0.1:" + port + uri); HttpURLConnection connection = hgu.init().connect(); String response = hgu.readResponse(); connection.disconnect(); System.out.println("=========================="); System.out.println(response); assertEquals(text, response); ListAppender nla = (ListAppender) logbackValve.getAppender("LIST"); assertEquals(1, nla.list.size()); IAccessEvent event = nla.list.get(0); assertEquals(uri, event.getRequestURI()); } @Test public void cookies() throws MalformedURLException, InterruptedException { String uri = "/cookies"; HttpGetUtil hgu = new HttpGetUtil("http://127.0.0.1:" + port + uri); hgu.init().addCookie("k0=v0").addCookie("k1=v1").connect(); String response = hgu.readResponse(); hgu.disconnect(); System.out.println("=========================="); System.out.println(response); assertEquals(text, response); ListAppender nla = (ListAppender) logbackValve.getAppender("LIST"); assertEquals(1, nla.list.size()); IAccessEvent event = nla.list.get(0); assertEquals(uri, event.getRequestURI()); List cookies = event.getCookies(); assertNotNull(cookies); assertEquals(2, cookies.size()); for(int i = 0; i < 2 ; i++) { assertEquals("k" + i, cookies.get(i).getName()); assertEquals("v" + i, cookies.get(i).getValue()); } } } ListAppender.java000066400000000000000000000015761523755721500374400ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/java/ch/qos/logback/access/tomcat_10_1/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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_10_1; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.AppenderBase; import java.util.ArrayList; import java.util.List; public class ListAppender extends AppenderBase { public List list = new ArrayList<>(); @Override protected void append(IAccessEvent eventObject) { list.add(eventObject); } } SampleServlet.java000066400000000000000000000021061523755721500376220ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/java/ch/qos/logback/access/tomcat_10_1/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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_10_1; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; class SampleServlet extends HttpServlet { String text; SampleServlet(String text) { this.text = text; } @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { PrintWriter writer = resp.getWriter(); writer.println(text); } } logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/resources/000077500000000000000000000000001523755721500272745ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_10_1_blackbox/src/test/resources/logback-stdout.xml000066400000000000000000000007101523755721500327360ustar00rootroot00000000000000 %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/000077500000000000000000000000001523755721500235145ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/pom.xml000066400000000000000000000066741523755721500250460ustar00rootroot00000000000000 4.0.0 ch.qos.logback.access parent 2.0.15 logback-access-tomcat_11_0_blackbox jar Logback Access Tomcat 11.0 Blackbox Module Logback Access Tomcat 11.0 Blackbox module org.assertj assertj-core ${assertj-core.version} org.junit.jupiter junit-jupiter-api ${junit-jupiter-api.version} org.junit.jupiter junit-jupiter-engine ${junit-jupiter-api.version} org.hamcrest hamcrest-library ${hamcrest.version} org.junit.jupiter junit-jupiter-params ${junit-jupiter-params.version} ch.qos.logback logback-core compile ch.qos.logback logback-classic ch.qos.logback logback-core ${logback-core.version} test-jar ch.qos.logback.access logback-access-common ch.qos.logback.access logback-access-common ${project.version} test-jar ch.qos.logback.access logback-access-tomcat ${project.version} org.apache.tomcat tomcat-catalina ${tomcat_11_0.version} org.apache.tomcat tomcat-coyote ${tomcat_11_0.version} org.slf4j slf4j-api org.apache.maven.plugins maven-surefire-plugin once plain true logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/000077500000000000000000000000001523755721500243035ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/000077500000000000000000000000001523755721500252625ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/java/000077500000000000000000000000001523755721500262035ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/java/ch/000077500000000000000000000000001523755721500265755ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/java/ch/qos/000077500000000000000000000000001523755721500273775ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/java/ch/qos/logback/000077500000000000000000000000001523755721500310015ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/java/ch/qos/logback/access/000077500000000000000000000000001523755721500322425ustar00rootroot00000000000000tomcat_11_0/000077500000000000000000000000001523755721500341725ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/java/ch/qos/logback/accessAccessTomcatVersionTest.java000066400000000000000000000020201523755721500416060ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/java/ch/qos/logback/access/tomcat_11_0/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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_11_0; import ch.qos.logback.access.tomcat.AccessTomcatVersionUtil; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class AccessTomcatVersionTest { @Test public void smoke() { String version = AccessTomcatVersionUtil.getCoreVersionBySelfDeclaredProperties(); assertNotNull(version); System.out.println("version="+version); assertTrue(version.startsWith("2.0")); } } EmbeddedTomcatTest.java000066400000000000000000000104201523755721500405330ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/java/ch/qos/logback/access/tomcat_11_0/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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_11_0; import ch.qos.logback.access.common.testUtil.HttpGetUtil; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.access.tomcat.LogbackValve; import ch.qos.logback.core.testUtil.RandomUtil; import jakarta.servlet.http.Cookie; import org.apache.catalina.Context; import org.apache.catalina.LifecycleException; import org.apache.catalina.connector.Connector; import org.apache.catalina.startup.Tomcat; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.File; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; public class EmbeddedTomcatTest { Tomcat tomcat; int port; LogbackValve logbackValve; String text = "

Welcome

"; @BeforeEach public void embed() throws LifecycleException { this.tomcat = new Tomcat(); this.port = RandomUtil.getRandomServerPort();; this.logbackValve = new LogbackValve(); tomcat.setBaseDir("/tmp"); //tomcat.setPort(port); Connector connector = tomcat.getConnector(); connector.setPort(port); tomcat.setConnector(connector);//getService().addConnector(connector); String contextPath = ""; String docBase = new File(".").getAbsolutePath(); Context context = tomcat.addContext(contextPath, docBase); String servletName = "SampleServlet"; String urlPattern = "/*"; setupValve("logback-stdout.xml"); //logbackValve.setContainer(context); context.getPipeline().addValve(logbackValve); tomcat.addServlet(contextPath, servletName, new SampleServlet(text)); context.addServletMappingDecoded(urlPattern, servletName); tomcat.start(); } private void setupValve(String fileName) { logbackValve.setFilename(fileName); logbackValve.setName("test"); } @AfterEach public void tearDown() throws LifecycleException, InterruptedException { tomcat.stop(); } @Test public void smoke() throws MalformedURLException, InterruptedException { String uri = "/moo"; HttpGetUtil hgu = new HttpGetUtil("http://127.0.0.1:" + port + uri); HttpURLConnection connection = hgu.init().connect(); String response = hgu.readResponse(); System.out.println("=========================="); System.out.println(response); assertEquals(text, response); ListAppender nla = (ListAppender) logbackValve.getAppender("LIST"); assertEquals(1, nla.list.size()); IAccessEvent event = nla.list.get(0); assertEquals(uri, event.getRequestURI()); } @Test public void cookies() throws MalformedURLException, InterruptedException { String uri = "/cookies"; HttpGetUtil hgu = new HttpGetUtil("http://127.0.0.1:" + port + uri); hgu.init().addCookie("k0=v0").addCookie("k1=v1").connect(); String response = hgu.readResponse(); hgu.disconnect(); System.out.println("=========================="); System.out.println(response); assertEquals(text, response); ListAppender nla = (ListAppender) logbackValve.getAppender("LIST"); assertEquals(1, nla.list.size()); IAccessEvent event = nla.list.get(0); assertEquals(uri, event.getRequestURI()); List cookies = event.getCookies(); assertNotNull(cookies); assertEquals(2, cookies.size()); for(int i = 0; i < 2 ; i++) { assertEquals("k" + i, cookies.get(i).getName()); assertEquals("v" + i, cookies.get(i).getValue()); } } } ListAppender.java000066400000000000000000000015761523755721500374400ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/java/ch/qos/logback/access/tomcat_11_0/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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_11_0; import ch.qos.logback.access.common.spi.IAccessEvent; import ch.qos.logback.core.AppenderBase; import java.util.ArrayList; import java.util.List; public class ListAppender extends AppenderBase { public List list = new ArrayList<>(); @Override protected void append(IAccessEvent eventObject) { list.add(eventObject); } } SampleServlet.java000066400000000000000000000021061523755721500376220ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/java/ch/qos/logback/access/tomcat_11_0/* * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2026, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v2.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_11_0; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; class SampleServlet extends HttpServlet { String text; SampleServlet(String text) { this.text = text; } @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { PrintWriter writer = resp.getWriter(); writer.println(text); } } logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/resources/000077500000000000000000000000001523755721500272745ustar00rootroot00000000000000logback-access-v_2.0.15/logback-access-tomcat_11_0_blackbox/src/test/resources/logback-stdout.xml000066400000000000000000000007071523755721500327440ustar00rootroot00000000000000 %h %l %u %user %date "%r" %s %b logback-access-v_2.0.15/pom.xml000066400000000000000000000450551523755721500163270ustar00rootroot00000000000000 4.0.0 ch.qos.logback.access parent 2.0.15 pom Logback-Access Parent logback-access project parent pom.xml file http://logback.qos.ch QOS.ch http://www.qos.ch 2005 Eclipse Public License - v 2.0 https://www.eclipse.org/legal/epl-v20.html GNU Lesser General Public License http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html https://github.com/qos-ch/logback scm:git@github.com:qos-ch/logback-access.git logback-access-common logback-access-common-blackbox logback-access-tomcat logback-access-tomcat_10_1_blackbox logback-access-tomcat_11_0_blackbox logback-access-jetty11 logback-access-jetty11-blackbox logback-access-jetty12 logback-access-jetty12-blackbox 2026-08-14T09:23:00Z 1.6.3 2.0.18 11 ${jdk.version} UTF-8 5.9.1 5.9.1 5.9.1 3.23.1 2.2 2.1.0 2.1.0 1.0.0 6.0.0 2.0.0-alpha-1 10.1.48 11.0.13 11.0.24 12.0.23 2.15.0 3.10.1 3.0.0-M7 3.3.0 3.1.1 3.2.0 3.1.0 3.2.2 3.6.0 3.0.0-M4 3.0.0-M1 3.2.0 5.1.9 3.1.0 0.9.0 ceki Ceki Gulcu ceki@qos.ch org.assertj assertj-core ${assertj-core.version} test org.junit.jupiter junit-jupiter-api ${junit-jupiter-api.version} test org.junit.jupiter junit-jupiter-engine ${junit-jupiter-api.version} test org.hamcrest hamcrest-library ${hamcrest.version} test ch.qos.logback.access logback-access-common ${project.version} ch.qos.logback logback-core ${logback-core.version} ch.qos.logback logback-classic ${logback-core.version} org.slf4j slf4j-api ${slf4j.version} jakarta.servlet jakarta.servlet-api ${jakarta.servlet.version} jakarta.mail jakarta.mail-api ${jakarta.mail.version} jakarta.activation jakarta.activation-api ${jakarta.activation.version} org.codehaus.janino janino ${janino.version} org.codehaus.janino commons-compiler ${janino.version} org.apache.maven.wagon wagon-ssh 2.10 org.apache.maven.plugins maven-clean-plugin 3.0.0 org.apache.maven.plugins maven-compiler-plugin ${maven-compiler-plugin.version} org.apache.maven.plugins maven-deploy-plugin ${maven-deploy-plugin.version} org.apache.maven.plugins maven-install-plugin ${maven-install-plugin.version} org.apache.maven.plugins maven-resources-plugin ${maven-resources-plugin.version} org.apache.maven.plugins maven-surefire-plugin ${maven-surefire-plugin.version} org.apache.maven.plugins maven-jxr-plugin ${maven-jxr-plugin.version} org.apache.maven.plugins maven-jar-plugin ${maven-jar-plugin.version} org.apache.maven.plugins maven-javadoc-plugin ${maven-javadoc-plugin.version} org.apache.maven.plugins maven-dependency-plugin ${maven-dependency-plugin.version} org.apache.maven.plugins maven-release-plugin ${maven-release-plugin.version} org.apache.maven.plugins maven-source-plugin ${maven-source-plugin.version} org.apache.maven.plugins maven-compiler-plugin ${jdk.version} org.apache.maven.plugins maven-jar-plugin true true org.apache.maven.plugins maven-source-plugin attach-sources jar test-jar org.apache.maven.plugins maven-javadoc-plugin true logback-access ${project.version} API logback-access-jetty11,logback-access-common-blackbox,logback-access-tomcat_10_1_blackbox,logback-access-tomcat_11_0_blackbox none https://docs.oracle.com/en/java/javase/11/docs/api/ Logback Access ch.qos.logback.access:ch.qos.logback.access.* org.apache.maven.plugins maven-jxr-plugin Logback-access ${project.version} Reference Logback-access ${project.version} Reference **/ch/qos/logback/access/tomcat_10_1/*.java **/ch/qos/logback/access/tomcat_11_0/*.java org.sonatype.central central-publishing-maven-plugin ${central-publishing-maven-plugin.version} true central logback-access-common-blackbox,logback-access-tomcat_10_1_blackbox,logback-access-tomcat_11_0_blackbox,logback-access-jetty11_blackbox,logback-access-jetty12_blackbox sonatype-nexus-staging https://oss.sonatype.org/service/local/staging/deploy/maven2/ license com.mycila license-maven-plugin ${license-maven-plugin.version}
src/main/licenseHeader.txt
false true true src/**/*.java src/**/*.groovy true true 1999 src/main/javadocHeaders.xml
javadocjar org.apache.maven.plugins maven-javadoc-plugin ${maven-javadoc-plugin.version} attach-javadocs jar none **/module-info.java sign-artifacts org.apache.maven.plugins maven-gpg-plugin 1.6 sign-artifacts verify sign