Hostxpeed
Login Get Started →
Server Management

How to Export Logs to CSV

4 min read
21 views
Jun 10, 2026

Prerequisites

Before exporting to CSV, make sure you have:

  • SSH access to your VPS
  • Basic knowledge of log format

Method 1: Simple CSV from Apache/Nginx Access Logs

Connect to your VPS:

ssh hxroot@YOUR_SERVER_IP -p 22

Extract CSV from access log:

awk '{print $1","$4","$5","$9","$10","$7}' /var/log/nginx/access.log > access.csv

Fields: IP, date, time, status, bytes, request.

Method 2: Add Header to CSV

echo "IP,Date,Time,Status,Bytes,Request" > access.csv
awk '{print $1","$4","$5","$9","$10","$7}' /var/log/nginx/access.log >> access.csv

Method 3: Process Syslog Format

Syslog to CSV (sample):

awk '{print $1","$2","$3","$5 ","$6","$7","substr($0, index($0,$9))}' /var/log/syslog > syslog.csv

Method 4: Using sed and cut

sed 's/ /,/g' /var/log/auth.log | cut -d',' -f1-6 > auth.csv

Method 5: Export journalctl to CSV

sudo journalctl --output=json-pretty | jq -r '[.timestamp, .hostname, .message] | @csv' > journal.csv

Method 6: Download CSV to Local Machine

scp hxroot@YOUR_SERVER_IP:/path/to/access.csv .

✅ Logs exported to CSV. Import into Excel or Google Sheets for analysis.

Was this article helpful?