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:
- Installed logrotate:
opkg install logrotate
- Created a folder for log backups:
mkdir -p /logs
- Set up system logging to save to
/logs/system.log
, committed the changes, and restarted the system. - Configured
/etc/logrotate.conf
as follows:
/logs/system.log {
daily
rotate 1000
dateext
dateformat -%Y-%m-%d
missingok
notifempty
compress
create 640 root adm
}
- Set up a cron job to run logrotate daily at 5 minutes past midnight:
5 0 * * * logrotate /etc/logrotate.conf
Kernel Log:
- Wrote a script (
kenellog_save.sh
) to retrieve the kernel log:
dmesg > /suncom/logs/kernel.log
- Set a cron job to run
kenellog_save.sh
daily at midnight:
0 0 * * * /etc/kernellog_save.sh
- 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:
- How can I log user activity in LuCI? If you have any suggestions or ideas, please share them.
- 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. Thank you!