Skip to content

Commit

Permalink
Merge pull request #3362 from arunans23/httpaccesslogs
Browse files Browse the repository at this point in the history
Disable default access logger and utilize log4j2 for http access logs
  • Loading branch information
arunans23 authored Jun 19, 2024
2 parents 31c8b8a + 3875944 commit 052edf9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions distribution/src/conf/access-log.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ access_log_suffix=.log
# file date format
access_log_file_date_format=yyyy-MM-dd

# enable or disable access logging to a custom file
access_log_enable=false
27 changes: 25 additions & 2 deletions distribution/src/conf/log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

# list of all appenders
#add entry "syslog" to use the syslog appender
appenders = CARBON_CONSOLE, CARBON_LOGFILE, AUDIT_LOGFILE, ATOMIKOS_LOGFILE, CARBON_TRACE_LOGFILE, osgi, SERVICE_LOGFILE, API_LOGFILE, ERROR_LOGFILE, CORRELATION, OPEN_TELEMETRY
appenders = CARBON_CONSOLE, CARBON_LOGFILE, AUDIT_LOGFILE, ATOMIKOS_LOGFILE, CARBON_TRACE_LOGFILE, osgi, SERVICE_LOGFILE, API_LOGFILE, ERROR_LOGFILE, CORRELATION, OPEN_TELEMETRY, HTTP_ACCESS_LOGFILE
#, syslog

# CARBON_CONSOLE is set to be a ConsoleAppender using a PatternLayout.
Expand Down Expand Up @@ -195,6 +195,24 @@ appender.CORRELATION.strategy.max = 20
appender.CORRELATION.filter.threshold.type = ThresholdFilter
appender.CORRELATION.filter.threshold.level = INFO

# Appender config to HTTP access logs
appender.HTTP_ACCESS_LOGFILE.type = RollingFile
appender.HTTP_ACCESS_LOGFILE.name = HTTP_ACCESS_LOGFILE
appender.HTTP_ACCESS_LOGFILE.fileName = ${sys:logfiles.home}/http_access.log
appender.HTTP_ACCESS_LOGFILE.filePattern = ${sys:logfiles.home}/http_access_%d{yyyy-MM-dd}.log
appender.HTTP_ACCESS_LOGFILE.layout.type = PatternLayout
appender.HTTP_ACCESS_LOGFILE.layout.pattern = %msg%n
appender.HTTP_ACCESS_LOGFILE.policies.type = Policies
appender.HTTP_ACCESS_LOGFILE.policies.time.type = TimeBasedTriggeringPolicy
appender.HTTP_ACCESS_LOGFILE.policies.time.interval = 1
appender.HTTP_ACCESS_LOGFILE.policies.time.modulate = true
appender.HTTP_ACCESS_LOGFILE.policies.size.type = SizeBasedTriggeringPolicy
appender.HTTP_ACCESS_LOGFILE.policies.size.size=1MB
appender.HTTP_ACCESS_LOGFILE.strategy.type = DefaultRolloverStrategy
appender.HTTP_ACCESS_LOGFILE.strategy.max = 20
appender.HTTP_ACCESS_LOGFILE.filter.threshold.type = ThresholdFilter
appender.HTTP_ACCESS_LOGFILE.filter.threshold.level = DEBUG

# Uncomment the below lines to use the Syslog Appender
#appender.syslog.type = Syslog
#appender.syslog.name = Syslog
Expand All @@ -205,7 +223,7 @@ appender.CORRELATION.filter.threshold.level = INFO
#appender.syslog.filter.threshold.type = ThresholdFilter
#appender.syslog.filter.threshold.level = DEBUG

loggers = AUDIT_LOG, SERVICE_LOGGER, API_LOGGER, trace-messages, org-apache-coyote, com-hazelcast, Owasp-CsrfGuard, \
loggers = AUDIT_LOG, SERVICE_LOGGER, API_LOGGER, PassThroughAccess, trace-messages, org-apache-coyote, com-hazelcast, Owasp-CsrfGuard, \
org-apache-axis2-wsdl-codegen-writer-PrettyPrinter, org-apache-axis2-clustering, org-apache-catalina, \
org-apache-tomcat, org-wso2-carbon-apacheds, org-apache-directory-server-ldap, \
org-apache-directory-server-core-event, com-atomikos, org-quartz, org-apache-jackrabbit-webdav, org-apache-juddi, \
Expand Down Expand Up @@ -315,6 +333,11 @@ logger.API_LOGGER.level = INFO
logger.API_LOGGER.appenderRef.SERVICE_LOGFILE.ref = API_LOGFILE
logger.API_LOGGER.additivity = false

logger.PassThroughAccess.name = org.apache.synapse.transport.http.access
logger.PassThroughAccess.level = DEBUG
logger.PassThroughAccess.appenderRef.HTTP_ACCESS_LOGFILE.ref = HTTP_ACCESS_LOGFILE
logger.PassThroughAccess.additivity = false

logger.trace-messages.name = trace.messages
logger.trace-messages.level = TRACE
logger.trace-messages.appenderRef.CARBON_TRACE_LOGFILE.ref = CARBON_TRACE_LOGFILE
Expand Down

0 comments on commit 052edf9

Please sign in to comment.