Logging all requests on the file system

The history mode logs all requests into a database. This can put a very significant strain on the database and can lead to insertion issues as the request table begins to host millions of records.

As an alternative to the history mode it’s possible to enable the auditing logger, which will log the details of each request in a file, which is periodically rolled. Secondary applications can then process these log files and built ad-hoc summaries off line.


The monitor.properties file can contain the following items to enable and configure file auditing:

  1. Go to the ${GEOSERVER_DATA_DIR}/monitoring and open the monitor.properties then append the following configuration:

  2. Replace ${TRAINING_ROOT} with the full path to the workshop root folder, and rememeber to always use forward slashes, /, in the path, regardless of the operating system. For example, on Windows the path might look like C:/data/Training_2.10.X-32

  3. Go to the Map Map Preview and open the geosolutions:states layer clicking on the OpenLayer link.

  4. Perform a few times zoom the map.

  5. Open the new created log file (named like geoserver_audit_yyyymmdd_nn.log) located at ${TRAINING_ROOT}.


    • audit.enable: is used to turn on the logger (it is off by default).
    • audit.path: is the directory where the log files will be created.
    • audit.roll_limit: is the number of requests logged into a file before rolling happens.


    The files are also automatically rolled at the beginning of each day.

Outputs and contents

The log directory will contain a number of log files following the geoserver_audit_yyyymmdd_nn.log pattern. The nn is increased at each roll of the file. The contents of the log directory will look like:


Customizing the log contents

The log contents are driven by three FreeMarker templates. We can customize them to have the log file be a csv file for example.

  1. On the file system navigate to the GeoServer data directory located at $GEOSERVER_DATA_DIR.

  2. In the monitoring directory create a new file named header.ftl (is used once when a new log file is created to form the first few lines of the file).

  3. Open header.ftl in the text editor of your choice and enter the following content (make sure to end the file with a newline):

    # start time,services,version,operation,url,response content type,total time,response length,error flag
  4. Create another file named content.ftl.

  5. Open content.ftl in the text editor of your choice and enter the following content (make sure to end the file with a newline):

    ${startTime?datetime?iso_utc_ms},${service!""},${owsVersion!""},${operation!""},"${path!""}${queryString!""}",${responseContentType!""},${totalTime},${responseLength?c},<#if error??>failed<#else>success</#if>
  6. Create a last file named footer.ftl, and leave its contents empty

  7. Run again a few requests, the log files should contain something like the following now:

    # start time,services,version,operation,url,response content type,total time,response lenght,error flag