Access Log Configuration
[]
Target groups
- Administrator (Web)
Context
The OC satellite supports an AccessLog and a SatelliteLog.
The AccessLog documents the requests received by the underlying webserver. It creates a technical documentation of network access and communication. Requests blocked or filtered from access to the OnlineChannel are documented within the access log only.
The SatelliteLog documents the requests as they are handled by the OnlineChannel.
The OC satellites are able to log to multiple targets. The default is to write logfiles within /logs subfolder of installation directory like ./logs/satellite.log.
The logging system's backend is provided through http://logback.qos.ch/LOGBack</a>.
The LOGBack configuration is documented http://logback.qos.ch/manual/configuration.htmlexternal</a>.
Access Log Configuration</a>
AccessLog is configured by the AccessLoggingConfiguration.xml within the SatelliteConfigurations group.
Patterns and Request Attributes
A request can be enriched by adding custom or standardized attributes. While getting routed to a host and instance of the satellite, the system adds custom attributes to the request. The following keys -embedded into %%reqAttribute{KEY}- can be used within the <pattern> definitions of log messages to output those attribute values.
- X-Cs-Log-Host the hostname of the virtual host handling the request (if any)
- X-Cs-Log-InstanceId the instanceId of the virtual host handling the request (if any)
- X-Cs-Log-InstanceId-Host the instanceId concatenated by the hostname of the virtual host handling the request (if any)
- X-Cs-Request-Id Unique ID of the request created and set by; equal to cs.requestId within LoggingConfiguration
Example
AccessLoggingConfiguration.xml
<dictionary>
<pid>com.censhare.oc.webserver.impl.AccessLogService</pid>
<property>
<key>config</key>
<Xml>
<configuration>
<!-- LOGBACK configuration -->
<appender name="FILE-HOST" class="ch.qos.logback.access.sift.SiftingAppender">
<discriminator class="ch.qos.logback.access.sift.AccessEventDiscriminator">
<key>host</key>
<defaultValue>unknown</defaultValue>
<fieldName>REQUEST_ATTRIBUTE</fieldName>
<additionalKey>X-Cs-Log-Host</additionalKey>
</discriminator>
<sift>
<appender name="FILE-HOST-${host}" class="ch.qos.logback.core.rolling.RollingFileAppender" bufferSize="262144">
<file>logs/access/${host}/request.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/access/${host}/request_%d{yyyy-MM-dd}.log.gz</fileNamePattern>
</rollingPolicy>
<encoder class="ch.qos.logback.access.PatternLayoutEncoder">
<pattern>%h %u %reqAttribute{X-Cs-Request-Id} [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}"</pattern>
</encoder>
</appender>
</sift>
</appender>
<appender name="GRAYLOG" class="com.censhare.oc.webserver.impl.log.appender.AccessLogAppender"/>
<appender-ref ref="FILE-HOST"/>
<appender-ref ref="GRAYLOG"/>
<!-- LOGBACK configuration -->
</configuration>
</Xml>
</property>
</dictionary>
Access Log Configuration</a>
Logging Configuration
The SatelliteLog is configured by the LoggingConfiguration within the SatelliteConfigurations.
Patterns and MDC
While request passes through the satellite system the related MDC context is enriched with various key/value data pairs available to logging system. The following keys -embedded into %X{KEY}- can be used within the <pattern> definitions of log messages: http://logback.qos.ch/manual/mdc.htmlLOGBack reference</a>
- cs.hostname server name request send to (by WebServerImpl)
- cs.remotePeer address of reqest origin (by WebServerImpl)
- cs.requestUrl the URL of request (by WebServerImpl)
- cs.requestId a uique id for reques (by WebServerImpl)
- cs.siteId siteId, name/id of site (by OCSiteImpl)
- cs.requestDelegate the delegate currently invoked (by OCSiteImpl)
- cs.requestState ['isResponsible' | 'handleRequest'] is delegate checking responsibility or is handling the request (by OCSiteImpl)
- cs.site.isResponsibleDuration duration (ms) it took the delegate to check if responsible (by OCSiteImpl)
- cs.site.handleRequestDuration duration (ms) it took the delegate handle request (by OCSiteImpl)
- cs.dsLocale locale of datastore session used (by ComponentRequestDelegate & LocaleNavigationTreeNodeParameterResolver)
- cs.navigationState active navItem asset id (by ComponentRequestDelegate)
- cs.rootComponent name of render root (by ComponentRequestDelegate)
- cs.componentState ['bindComponents'|'executeActions'|'render'] current init step (by ComponentRequestDelegate)
- cs.crd.timeWaitingForSemaphoreInMs wait time to get execution slot (by ComponentRequestDelegate)
- cs.crd.timeProcessingRequestInMs execution time (by ComponentRequestDelegate)
- cs.crd.totalTimeProcessingRequestInMs total req handle time (by ComponentRequestDelegate)
Example
LoggingConfiguration
<dictionary>
<pid>com.censhare.satellite.launcher.LoggingService</pid>
<property>
<key>config</key>
<Xml>
<configuration>
<!-- LOGBACK configuration -->
<statusListener class="com.censhare.satellite.logging.FileStatusListener"/>
<property scope="context" name="customer" value="acme"/>
<property scope="context" name="project" value="acme-website"/>
<property scope="context" name="view" value="staging"/>
<property scope="context" name="env" value="prod"/>
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
<logger name="com.censhare.oc.system.site.DefaultSessionManager" level="ALL"/>
<root level="INFO">
<appender-ref ref="STDERR"/>
</root>
<!-- LOGBACK configuration -->
</configuration>
</Xml>
</property>
</dictionary>