Generate a basic log indicating which users are accessing which pages in Confluence. Application servers are able to log the requested URL, but they cannot determine the currently logged in user. This log is not currently formatted to be accessible to web log analysis tools such as AwStats as it lacks a host and get method, so must be viewed manually.
Similar to JIRA, Confluence has a built-in access logging mechanism, which shows the user and URL invoked. To enable it, you need to modify a couple of configuration files and restart Confluence.
Configuring the AccessLogFilter
There is a simple AccessLogFilter in Confluence that can be enabled via log4j.properties and web.xml.
You need to uncomment these lines in log4j.properties:
log4j.category.com.atlassian.confluence.util.AccessLogFilter=INFO, confluencelog
log4j.additivity.com.atlassian.confluence.util.AccessLogFilter=false
And enable the filter in web.xml by removing the comments around these lines:
<filter-mapping>
<filter-name>AccessLogFilter</filter-name>
<url-pattern>/display/*</url-pattern>
</filter-mapping>
Enabling this AccessLogFilter will result in logging information being stored in the standard confluence log files.
Advanced configuration
After this is working, you could redirect the access log to a different file by adding a new RollingFileAppender at the top of log4j.properties:
log4j.appender.accesslog=org.apache.log4j.RollingFileAppender
log4j.appender.accesslog.Threshold=DEBUG
log4j.appender.accesslog.File=${catalina.home}/logs/atlassian-confluence-access.log
log4j.appender.accesslog.MaxFileSize=20480KB
log4j.appender.accesslog.MaxBackupIndex=5
log4j.appender.accesslog.layout=com.atlassian.confluence.util.PatternLayoutWithStackTrace
log4j.appender.accesslog.layout.ConversionPattern=%d %p [%c{4}] %M %m%n
To enable this logger, you need to add 'accesslog' to the log4j.rootLogger property, and change the AccessLogFilter logger line from 'confluencelog' to 'accesslog'.
The web.xml url-pattern given above only matches page views (/display/*). You could change the url-pattern, or duplicate the entire filter-mapping to log access for different kinds of access (/admin/* for admin functions, /pages/* for edits and creates, etc. Note that /pages/editpage.action* doesn't work).
What is logged
The format produced is the following values separated by spaces:
1. Username or '-' if no user
2. URL
3. VM free memory at start of request (in KB)
4. Change in free memory after request is finished (in KB)
5. Time taken for request (in ms).
The above may be preceded by additional log4j-generated text, depending on the log4j pattern which is configured.
Another option: Google Analytics
Google Analytics can be easily integrated with Confluence for access tracking.
After signing up, copy the Javascript and paste it into the 'Before end of <body>' section of Administration, Custom HTML. This will put the Javascript on every page generated by Confluence.
This might not work correctly if your users are behind a firewall or authenticated proxy.