This is an automated email from the ASF dual-hosted git repository. cziegeler pushed a commit to branch issues/SLING-11898 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-engine.git
The following commit(s) were added to refs/heads/issues/SLING-11898 by this push: new f61f0ce SLING-11898 : Make patterns for access and request log configurable f61f0ce is described below commit f61f0ce7c17f6065cb01cdc0276c0e34f9854755 Author: Carsten Ziegeler <cziege...@apache.org> AuthorDate: Fri Jun 2 07:14:55 2023 +0200 SLING-11898 : Make patterns for access and request log configurable --- .../sling/engine/impl/log/RequestLogger.java | 35 +++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/apache/sling/engine/impl/log/RequestLogger.java b/src/main/java/org/apache/sling/engine/impl/log/RequestLogger.java index edd2178..dd8f8be 100644 --- a/src/main/java/org/apache/sling/engine/impl/log/RequestLogger.java +++ b/src/main/java/org/apache/sling/engine/impl/log/RequestLogger.java @@ -52,9 +52,7 @@ public class RequestLogger { "The request log logs the entry and exit of each request into and "+ "out of the system together with the entry time, exit time, time to process "+ "the request, a request counter as well as the final status code and response "+ - "content type. In terms of Request Logger Service formats, request entry is "+ - "logged with the format \"%t [%R] -> %m %U%q %H\" and request exit is logged "+ - "with the format \"%{end}t [%R] <- %s %{Content-Type}o %Dms\".") + "content type. The format can be configured with the Request Log Entry/Exit Format setting.") String request_log_output() default "logs/request.log"; @AttributeDefinition(name = "Request Log Type", @@ -71,16 +69,26 @@ public class RequestLogger { }) int request_log_outputtype() default 0; + @AttributeDefinition(name = "Request Log Entry Format", + description = "The format of the request log. The request entry is "+ + "logged with the format \"%t [%R] -> %m %U%q %H\" by default." + ) + String request_log_entry_format() default REQUEST_LOG_ENTRY_FORMAT; + + @AttributeDefinition(name = "Request Log Exit Format", + description = "The format of the request log. The request exit is logged "+ + "with the format \"%{end}t [%R] <- %s %{Content-Type}o %Dms\" by default." + ) + String request_log_exit_format() default REQUEST_LOG_EXIT_FORMAT; + @AttributeDefinition(name = "Enable Request Log", description = "Whether to enable Request logging or not.") boolean request_log_enabled() default true; @AttributeDefinition(name = "Access Log Name", description = "Name of the destination for the request log. "+ - "The access log writes an entry for each request as the request terminates "+ - "using the NCSA extended/combined log format. In terms of Request Logger "+ - "Service formats the access log is written with the format "+ - "\"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"\".") + "The access log writes an entry for each request as the request terminates. "+ + "The format of the access log can be configured by the Access Log Format setting.") String access_log_output() default "logs/access.log"; @AttributeDefinition(name = "Access Log Type", @@ -97,6 +105,13 @@ public class RequestLogger { }) int access_log_outputtype() default 0; + @AttributeDefinition(name = "Access Log Format", + description = "The default format for the access log is using the NCSA extended/combined log "+ + "format. In terms of Request Logger Service formats the access log is written with the format "+ + "\"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"\"." + ) + String access_log_format() default ACCESS_LOG_FORMAT; + @AttributeDefinition(name = "Enable Access Log", description = "Whether to enable Access logging or not.") boolean access_log_enabled() default true; @@ -135,14 +150,14 @@ public class RequestLogger { // prepare the request loggers if a name is configured and the // request loggers are enabled if (config.request_log_output() != null && config.request_log_enabled()) { - createRequestLoggerService(services, bundleContext, true, REQUEST_LOG_ENTRY_FORMAT, config.request_log_output(), config.request_log_outputtype()); - createRequestLoggerService(services, bundleContext, false, REQUEST_LOG_EXIT_FORMAT, config.request_log_output(), config.request_log_outputtype()); + createRequestLoggerService(services, bundleContext, true, config.request_log_entry_format(), config.request_log_output(), config.request_log_outputtype()); + createRequestLoggerService(services, bundleContext, false, config.request_log_exit_format(), config.request_log_output(), config.request_log_outputtype()); } // prepare the access logger if a name is configured and the // access logger is enabled if (config.access_log_output() != null && config.access_log_enabled()) { - createRequestLoggerService(services, bundleContext, false, ACCESS_LOG_FORMAT, config.access_log_output(), config.access_log_outputtype()); + createRequestLoggerService(services, bundleContext, false, config.access_log_format(), config.access_log_output(), config.access_log_outputtype()); } }