Implementing Detailed Log Collection and Backup in OpenWrt

Hello, I am developing a router for use on ships. Due to the nature of maritime environments, immediate responses to errors are not always possible. Therefore, I am planning to implement detailed logging and use this data for product improvements through follow-up actions. I am currently implementing log collection and backup tasks in OpenWrt and would like to ask for your advice.

I aim to collect and back up three types of logs: system logs, kernel logs, and user activity logs.

Here are the steps I have taken so far:

System Log:

  1. Installed logrotate:
    opkg install logrotate
  2. Created a folder for log backups:
    mkdir -p /logs
  3. Set up system logging to save to /logs/system.log, committed the changes, and restarted the system.
  4. Configured /etc/logrotate.conf as follows:

/logs/system.log {
daily
rotate 1000
dateext
dateformat -%Y-%m-%d
missingok
notifempty
compress
create 640 root adm
}

  1. Set up a cron job to run logrotate daily at 5 minutes past midnight:
    5 0 * * * logrotate /etc/logrotate.conf

Kernel Log:

  1. Wrote a script (kenellog_save.sh) to retrieve the kernel log:
    dmesg > /suncom/logs/kernel.log
  2. Set a cron job to run kenellog_save.sh daily at midnight:
    0 0 * * * /etc/kernellog_save.sh
  3. Configured /etc/logrotate.conf for kernel logs as follows:

/logs/kernel.log {
daily
rotate 1000
dateext
dateformat -%Y-%m-%d
missingok
notifempty
compress
create 640 root adm
}

User Activity Log:
I want to record and back up user activities in LuCI, such as login, property changes, and setting modifications. However, I haven't found a method for this part yet.

I have two questions:

  1. How can I log user activity in LuCI? If you have any suggestions or ideas, please share them.
  2. Is the method I am using to collect system and kernel logs optimal? If there is a more efficient way, please let me know.

I am new to OpenWrt, having been introduced to it through this project. As I lack experience, I am in need of guidance and assistance. I appreciate any feedback or advice you can provide. :ear: Thank you!

1 Like

Hi @euna ,
I also want to log user activity, but don't know how to get Luci logs.
Have you done this? if "yes", i really appreciate any guideline you can provide.
Thanks

LuCI does not produce any activity logs. The closest you could do is switching the webserver to something bigger like nginx or lighttpd and setup HTTP access logging, probably restricted to a few specific endpoints such as /ubus (or /cgi-bin/luci/admin/ubus)