Google Cloud Logging
Cloud Logging is the managed logging service provided by Google Cloud.
The integration here also provides automatic support for associating a web request trace ID with the corresponding log entries
by retrieving the X-B3-TraceId
or x-cloud-trace-context
header values.
Configuration
Support is enabled by including the following dependency in the WAR overlay:
1
2
3
4
5
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-gcp-logging</artifactId>
<version>${cas.version}</version>
</dependency>
1
implementation "org.apereo.cas:cas-server-support-gcp-logging:${project.'cas.version'}"
1
2
3
4
5
6
7
8
9
dependencyManagement {
imports {
mavenBom "org.apereo.cas:cas-server-support-bom:${project.'cas.version'}"
}
}
dependencies {
implementation "org.apereo.cas:cas-server-support-gcp-logging"
}
1
2
3
4
5
6
7
8
9
10
dependencies {
/*
The following platform references should be included automatically and are listed here for reference only.
implementation enforcedPlatform("org.apereo.cas:cas-server-support-bom:${project.'cas.version'}")
implementation platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
*/
implementation "org.apereo.cas:cas-server-support-gcp-logging"
}

Due to the way logging is set up, the Google Cloud project ID and credentials
defined in CAS properties are ignored. Instead, you should set the GOOGLE_CLOUD_PROJECT
and GOOGLE_APPLICATION_CREDENTIALS
environment variables to the project ID and credentials
private key location, where necessary. Alternatively, the Google Cloud project ID can also be set directly
in the logging configuration.
This is an example of the logging configuration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<Configuration packages="org.apereo.cas.logging">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<JsonLayout locationInfo="false"
includeStacktrace="true"
objectMessageAsJsonObject="true"
compact="true"
properties="false"
eventEol="true"
includeTimeMillis="false">
<KeyValuePair key="time" value="$${event:timestamp:-}"/>
<KeyValuePair key="timestampSeconds" value="$${ctx:timestampSeconds:-}"/>
<KeyValuePair key="timestampNanos" value="$${ctx:timestampNanos:-}"/>
<KeyValuePair key="severity" value="$${ctx:severity:-}"/>
<KeyValuePair key="labels" value="$${ctx:labels:-}"/>
<KeyValuePair key="httpRequest" value="$${ctx:httpRequest:-}"/>
<KeyValuePair key="logging.googleapis.com/sourceLocation" value="$${ctx:sourceLocation:-}"/>
<KeyValuePair key="logging.googleapis.com/spanId" value="$${ctx:spanId:-}"/>
<KeyValuePair key="logging.googleapis.com/trace" value="$${ctx:traceId:-}"/>
</JsonLayout>
</Console>
<!-- Update the projectId, or remove and let CAS determine the project id automatically -->
<GoogleCloudAppender name="GoogleCloudAppender"
projectId="...">
<AppenderRef ref="casConsole"/>
</GoogleCloudAppender>
</Appenders>
<Loggers>
<Logger name="org.apereo.cas" includeLocation="true"
level="INFO" additivity="false">
<AppenderRef ref="GoogleCloudAppender"/>
</Logger>
</Loggers>
</Configuration>