I wrote a small bash script, which enables to search for words or exclude words in the nextcloud.log by attributes.
Some command examples:
- Show only log entries for username containing “peter”:
$ cat nextcloud.log \
| nc-log-filter --search user:peter
- Show only log entries where username does neither contain “peter” nor “susan” nor the message containing “dirty table reads”
$ cat nextcloud.log \
| nc-log-filter \
--not user:peter \
--not user:susan \
--not message:"dirty table reads"
- Suppress all level 0 messages
cat nextcloud.log | nc-log-filter --not level:0
Using tail -f to watch output works fine too:
tail -f nextcloud.log | nc-log-filter –-search user:peter
NOTE:
The script is not tolerant to errors in key names.
Example output:
{
"reqId": "jAN7l3ID4cntmPdEO530",
"level": 0,
"time": "2025-12-19T12:30:02+00:00",
"remoteAddr": "",
"user": "--",
"app": "cron",
"method": "",
"url": "--",
"message": "Finished job OCA\\Talk\\BackgroundJob\\CheckHostedSignalingServer (id: 49164, arguments: null) in 0 seconds",
"userAgent": "--",
"version": "32.0.2.2",
"data": {
"app": "cron"
}
}
{
"reqId": "yZYS2ihxlUUTH2DFOqJI",
"level": 1,
"time": "2025-12-19T12:32:07+00:00",
"remoteAddr": "3.4.5.6",
"user": "--",
"app": "core",
"method": "GET",
"url": "/index.php",
"message": "Trusted domain error. \"3.4.5.6\" tried to access using \"1.2.3.4\" as host.",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0",
"version": "32.0.2.2",
"data": {
"app": "core"
}
...
Script Source: