1

We have Beaglbone Black based custom board with Wifi chip
We have following entry in the rsyslog.conf

# Redirect all kernel messages including dmesg to /var/log/dmesglog
kern.*                         :omfile:$dmesg_log_rotation

dmesglog is flooded by wifi logs which starts with mlan0 So I changed rule as follows,

# Redirect all kernel messages including dmesg to /var/log/dmesglog
kern.*, !contains, "mlan0" :omfile:$dmesg_log_rotation

However those logs still continues to flood the dmesglog.

Can someone suggest me what is wrong with that log ?
Any other suggestion for rule ? any pointers ?

EDIT:
After some digging I found that rsyslogd -N1 can be used to check the rsyslog.conf. And that check pointed out error. I am trying to correct rule somehow.

EDIT2
I changed the rule as follows however now I don't see anything in the dmesglog

# Redirect all kernel messages including dmesg to /var/log/dmesglog
if ( 'kern.*' contains "mlan0" ) then{ action( type="omfile" file="*" ) } else { action( type="omfile" file="$dmesg_log_rotation" )}
1

Try this:

# Redirect all kernel messages including dmesg to /var/log/dmesglog
:msg, contains, "mlan0" ~
kern.*                         :omfile:$dmesg_log_rotation

According to rsyslogd documentation you should first discard the selected messages.


If you wish to put the filtered messages to a separate file, you can write something like:

# Redirect all "mlan0" to /var/log/mlan.log
:msg, contains, "mlan0" :omfile:/var/log/mlan.log
:msg, contains, "mlan0" ~
# Redirect all kernel messages including dmesg to /var/log/dmesglog
kern.*                         :omfile:$dmesg_log_rotation

Unfortunately, rsyslog doesn't support filtering exactly by the kernel module name, but you can try different properties (msg is only one of them), and you can specify the filter rule more accurately using rules "startswith", "isequal" or "regex". Full list of properties and rules is here (look below "Available Properties".
So you should try, for example:

:programname, startswith, "mlan" :omfile:/var/log/mlan.log

Or:

:syslogtag, regex, "^mlan[0-9]" :omfile:/var/log/mlan.log

I don't know If any property would contain the kernel mode. Anyway you can always filter by msg with regex.

:msg, regex, "^write-regex-matching-your-module-log-output" :omfile:/var/log/mlan.log
|improve this answer|||||
  • Just tempted to ask, can we redirect logs from particular kernel module to different file ? – ART Nov 28 '17 at 18:42
  • 1
    You can redirect filtered messages to a different file. I added my answer with more examples. Hope it will help. – tifssoft Nov 28 '17 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.