1 min read

Convert Nginx Log into HTML

If you have Nginx logs and want to present them more elegantly, consider using GoAccess instead of manually parsing them with a spreadsheet or other tools.

Assuming you have raw Nginx log files like this:

ls
domain.com-access.log
domain.com-access.log.1
domain.com-access.log.2.gz
domain.com-access.log.3.gz
# ... and so on

To filter the logs for a specific path, use the following commands:

cat domain.com-access.log | grep /path/of/url >> filtered.log
cat domain.com-access.log.1 | grep /path/of/url >> filtered.log
 
# use "zcat" for gzip file
zcat domain.com-access.log.*.gz | grep /path/of/url >> filtered.log

Export the filtered logs to HTML using GoAccess:

cat filetered.log |  docker run --rm -i -e LANG=en allinurl/goaccess -a -o html --log-format COMBINED - > report.html

In the end, you’ll have a file named report.html that can be opened in any browser, featuring an attractive and user-friendly interface.

GoAccess HTML UI