To generate a report from a log file, you use the lr_log2report command. This command expects a log file on standard input and will output the report on standard output. It takes the Lire™ service of the log file as its argument. The various supported services can be found by running lr_check_service -l, see the lr_log2report(1) man page for details. 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.
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 combined < \ /var/log/apache/access_log > ~/report.txt
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_page combined < \ /var/log/apache/access_log > ~/apache.tar
This will create a tar archive containing the report. Unpack it using the tar command, or unpack it on the fly, doing:
$ lr_run lr_log2report -o html_page combined < \ /var/log/apache/access_log | tar xf -
This will create a report directory in the current working directory, holding the HTML report file.
Lire™ can generate charts (pie chart, bar chart, line graph or histogram) for some reports. If you have the necessary programs installed, 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 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/.