We have Nextcloud 22.1.1 deployed.
We would like to receive logs of user activity in order to record the actions that Nextcloud users perform. The default log does not record detailed information about user activity. What can be done in this case?
Sorry for commenting on an old post but i thought it might help somone in the future.
Simple bash script to have a more readable format of the audit.log. Might not be the best script you have seen but the output is readable and searchable.
#!/bin/bash
# Input file containing the audit log
input_file="/path/to/audit.log"
# Output file to store the cleaned-up log entries
output_file="path/to/clean_audit_log.txt"
# Read each line from the input file
while IFS= read -r line; do
# Extract relevant fields from the JSON log entry using grep and sed
time=$(echo "$line" | grep -oP '(?<="time":")[^"]+')
user=$(echo "$line" | grep -oP '(?<="user":")[^"]+')
method=$(echo "$line" | grep -oP '(?<="method":")[^"]+')
url=$(echo "$line" | grep -oP '(?<="url":")[^"]+')
message=$(echo "$line" | grep -oP '(?<="message":")[^"]+')
user_agent=$(echo "$line" | grep -oP '(?<="userAgent":")[^"]+')
# Format the extracted fields into a cleaned-up log entry
cleaned_entry="Time: $time\nUser: $user\nMethod: $method\nURL: $url\nMessage: $message\nUser Agent: $user_agent\n"
# Append the cleaned-up log entry to the output file
echo -e "$cleaned_entry\n" >> "$output_file"
done < "$input_file"
Thank you @Irdi in fact I’m wondering why you going the hard way to parse the log manually. Please look at this post Nextcloud Client - See Version used by all users - #3 by wwe to see how to use jq extract useful information from Nextcloud json logs (same technique applies for nextcloud.log and audit.log)