Enabling access logging
By enabling access logging, you can log each of the HTTP (or HTTPS) accesses to your CollectionSpace system. By doing so, you can view listings of:
- Requests made to your system, including their URLs and query parameters.
- Timestamps identifying when the responses to these requests were returned.
- Details about each response, including status codes indicating success or error, and the number of bytes returned.
- (Optional) The round-trip timings for each request made to your system, useful when tuning performance.
Enabling access logging - which is turned off by default - is a recommended best practice. Logging accesses to your CollectionSpace system can often help you troubleshoot configuration, operational, security, and performance issues.
Task Description
To enable access logging, uncomment a specific section of a single configuration file, located within your CollectionSpace server folder.
To disable such logging, comment out that section once again.
You will need to restart your server each time you make this change.
Prerequisites
To make these changes, you will need to know how to edit files on the host on which CollectionSpace system is running, and have the filesystem permissions to do so.
You will also need to know how to execute commands from the command line, including commands to stop and start the CollectionSpace servers.
Procedure
To enable access logging:
- If the CollectionSpace server is running, stop the server.
- Edit the file
$CSPACE_JEESERVER_HOME/conf/server.xml
(or%CSPACE_JEESERVER_HOME%\conf\server.xml
on a Windows system). Uncomment the
AccessLogValve
directive in this file, by removing any XML comment markers (<!--
and–>
) that may be present around that section:<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
(Optional) To add round-trip timings to access log entries, identifying how long each request to your CollectionSpace system took to process and send a response, change the value of the
pattern=
attribute from"common"
to the pattern value below, exactly as shown:<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b %T" resolveHosts="false"/>
- Restart the CollectionSpace server.
Test
After making this change and restarting the CollectionSpace server, look in your server's log directory for access log files.
The server log directory is:
$CSPACE_JEESERVER_HOME/logs
The access log files will all have filenames containing access_log
and will look something like this example: localhost_access_log.2012-07-25.txt
. Their names may vary, depending on your server and the current date.
Summary
By following the steps above, you will have enabled access logging for your CollectionSpace system. This will log data about requests to your system, and the responses returned, which can be useful when troubleshooting configuration or operational issues.
See Also
It would be useful to add links here to additional logging documentation (most of this to be created in the future), around enabling and configuring:
- Logging in the Services layer
- Logging in the Application layer
- Logging in PostgreSQL