Background & Context

    • Apache log files.
    • Native log file format of the Apache web server.
    • Common variants are Apache Common Log and Apache Access Log.
    • Is used by MathLM, the Wolfram System license manager.
    • Plain text format.
    • Stores information about web server transactions.
    • Represents each record as a line of text.
    • Allows user-customized record formats.


  • Import["file","ApacheLog"] imports an Apache log file.
  • Import["file","ApacheLog"] reads an Apache log file and returns the contents as a table.
  • Import["file",{"ApacheLog",elem}] imports the specified element from an Apache log file.
  • Import["file",{"ApacheLog",{elem1,elem2,}}] imports multiple elements.
  • The format "ApacheLog" must always be specified when importing Apache log files.
  • See the following reference pages for full general information:
  • Importimport from a file
    CloudImportimport from a cloud object
    ImportStringimport from a string
    ImportByteArrayimport from a byte array

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Summary"summary of the file
    "Rules"list of rules for all available elements
  • Data representation element:
  • "Data"content of the file represented as a list of lists
  • Import by default uses the "Data" element for Apache log files.
  • Selecting individual data fields:
  • "Attachments"files attached to the message
    "ByteCount"byte size of the object returned to the client
    "Date"date and time of the transaction, given as a string
    "Referrer"site from which the client reports having been referred
    "RemoteHost"IP address or hostname of the client
    "RemoteUser"user ID of the client as determined by HTTP authentication
    "RequestLine"the client request as a string, normally containing the path of the requested object and information about the protocol
    "SessionID"a string that identifies the user session
    "StatusCode"the status code that the server returns to the client, as defined in the HTTP specification (RFC2616)
    "UserAgent"browser identification as reported by the client


  • Import option:
  • "DataFormat"Automaticformat specification, given as a list of data representation elements and separators representing one record
  • To import a custom log format, "DataFormat" can be used to specify the format of each record as a combination of data elements and record separators.
  • Import of Common Log files uses the setting "DataFormat"->{"RemoteHost"," ","ClientID"," ","RemoteUser"," " ,"Date"," \"","RequestLine","\" ","StatusCode"," " ,"ByteCount"}.
  • The default format of Access Log files is given by {"RemoteHost"," ","ClientID"," ","RemoteUser"," " ,"Date"," \"","RequestLine","\" ","StatusCode"," " ,"ByteCount", " \"","Referrer","\" \"","UserAgent","\""}.


Basic Examples  (1)

Import an entire log file as a list of records:

Show the Import elements available in this file:

Read only the date fields:

Read all server requests: