You are viewing the development documentation for the Apereo CAS server. The
functionality presented
here is not officially released yet.
This is a work in progress and will be continually updated as development moves forward. To view
the documentation for a specific Apereo CAS server release, please choose an appropriate version.
The release schedule is also available here.
Logging
CAS provides a logging facility that logs important informational events like authentication success and failure; it can be customized to produce additional information for troubleshooting. CAS uses the Slf4J Logging framework as a facade for the Log4J engine by default.
The log4j configuration file is located in cas-server-webapp/src/main/webapp/WEB-INF/classes/log4j2.xml. By default logging is set to INFO for all functionality related to org.jasig.cas code and WARN for messages related to Spring framework, etc. For debugging and diagnostic purposes you may want to set these levels to DEBUG.
Usage Warning!
When in production though, you probably want to run them both as `WARN`.
Components
The log4j configuration is by default loaded using the following components at cas-server-webapp/src/main/webapp/WEB-INF/spring-configuration/log4jConfiguration.xml:
It is often time helpful to externalize log4j2.xml to a system path to preserve settings between upgrades. The location of log4j2.xml file by default is on the runtime classpath and at minute intervals respective. These may be overridden by the cas.properties file
Configuration
The log4j2.xml file by default at WEB-INF/classes provides the following appender elements that decide where and how messages from components should be displayed. Two are provided by default that output messages to the system console and a cas.log file:
Refresh Interval
The log4j2.xml itself controls the refresh interval of the logging configuration. Log4j has the ability to automatically detect changes to the configuration file and reconfigure itself. If the monitorInterval attribute is specified on the configuration element and is set to a non-zero value then the file will be checked the next time a log event is evaluated and/or logged and the monitorInterval has elapsed since the last check. This will allow you to adjust the log levels and configuration without restarting the server environment.
Appenders
Loggers
Additional loggers are available to specify the logging level for component categories.
If you wish enable another package for logging, you can simply add another Logger element to the configuration. Here is an example:
Log Data Sanitation
For security purposes, CAS by default will attempt to remove TGT and PGT ids from all log data. This will of course include messages that are routed to a log destination by the logging framework as well as all audit messages. A sample follows below:
Certain number of characters are left at the trailing end of the ticket id to assist with troubleshooting and diagnostics. This is achieved by providing a specific binding for the SLF4j configuration.
Audits
CAS uses the Inspektr framework for auditing purposes and statistics. The Inspektr project allows for non-intrusive auditing and logging of the coarse-grained execution paths e.g. Spring-managed beans method executions by using annotations and Spring-managed @Aspect-style aspects.
Components
AuditTrailManagementAspect
Aspect modularizing management of an audit trail data concern.
Slf4jLoggingAuditTrailManager
AuditTrailManager that dumps auditable information to a configured logger based on SLF4J, at the INFO level.
JdbcAuditTrailManager
AuditTrailManager to persist the audit trail to the AUDIT_TRAIL table in a rational database.
TicketAsFirstParameterResourceResolver
ResourceResolver that can determine the ticket id from the first parameter of the method call.
TicketOrCredentialPrincipalResolver
PrincipalResolver that can retrieve the username from either the Ticket or from the Credential.
Configuration
Audit functionality is specifically controlled by the WEB-INF/spring-configuration/auditTrailContext.xml. Configuration of the audit trail manager is defined inside deployerConfigContext.xml.
Database Audits
By default, audit messages appear in log files via the Slf4jLoggingAuditTrailManager. If you intend to use a database for auditing functionality, adjust the audit manager to match the sample configuration below:
You’ll need to have a dataSource that defines a connection to your database. The following snippet
demonstrates a data source that connects to HSQLDB v1.8:
In order to configure the dataSource you will furthermore need additional dependencies
in the pom.xml file that deal with creating connections.
You will also need the dependency for the database driver that you have chosen.
Finally, the following database table needs to be created beforehand:
You may need to augment the syntax and column types per your specific database implementation.