Generating A Report From A Log File

To generate a report from a log file, you use the lr_log2report command. This command expects the log file on standard input and will output the report on standard output. It takes three arguments: a file where the error message will be saved, the superservice and the service of the log file. (The various values available for the superservice and service argument can be found in lr_log2report(1) man page). The lr_log2report command will log a lot of information on standard error. You can use the lr_run wrapper to filter those messages according to your preferences.

Note

The file specified in the first argument will only be created if serious errors are detected. It will contain a short explanation of what went wrong and will suggest possible causes of the problem: bad service, invalid log lines, etc. This is the error message that is sent back by the responder. In interactive use, it's probably usefull only when debugging.

Example 3.2. Generating a Report With lr_log2report

This is the way to generate a report in the default output format for a log file taken from an Apache log server.

$ lr_run lr_log2report /tmp/error www combined < \
 /var/log/apache/access_log > ~/report.txt
          

Selecting Output Format

Another output format than the default one (usually text) can be selected by using the -o switch with the lr_log2report command.

Example 3.3. Generating A HTML Report

To generate a HTML report from the same log file as above, you would use the following command:

$ lr_run lr_log2report -o html /tmp/error www combined < \
   /var/log/apache/access_log > ~/apache.html
	    

Including Charts in the Report

Lire can generate charts (pie chart, bar chart, line graph or histogram) for some reports. If you have the necessary requirements, you can tell lr_log2report to make the charts by adding the -i option to your command line. (Only the PDF, HTML, XHTML, RTF and DocBook XML output formats support charts.)

Example 3.4. Generating A HTML Report With Charts

To include charts with the HTML report, you would use the following command:

$ lr_run lr_log2report -o html -i /tmp/error www combined < \
   /var/log/apache/access_log | tar xfC - /tmp
	    

In this case, we piped the output to tar because what is outputted is a tar file. This tar file contains a directory called report which contains the charts in PNG format and the HTML report in the index.html file. The command creates a directory /tmp/report/.