dmesglog에 대한 rsyslog.conf 규칙이 작동하지 않습니다.

dmesglog에 대한 rsyslog.conf 규칙이 작동하지 않습니다.

Wi-Fi 칩이 포함된 Beaglbone Black 기반의 맞춤형 보드가 있습니다.
다음 항목이 있습니다.rsyslog.conf

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

dmesglog는 다음과 같이 시작하는 Wi-Fi 로그로 가득 차 있습니다. mlan0그래서 규칙을 다음과 같이 변경했습니다.

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

그러나 이러한 로그는 여전히 dmesglog를 계속해서 넘치게 합니다.

이 로그에 무슨 문제가 있는지 알려주실 분 계신가요?
규칙에 대한 다른 제안이 있나요? 어떤 지침이 있나요?

편집하다:
좀 더 조사한 결과 rsyslogd -N1check를 사용할 수 있다는 사실을 발견했습니다 rsyslog.conf. check에서 오류가 지적되었습니다. 어떻게든 규칙을 바로잡으려고 노력 중이에요.

편집 2
다음과 같이 규칙을 변경했는데 이제 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

이 시도:

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

~에 따르면rsyslogd 문서먼저 선택한 메시지를 삭제해야 합니다.


필터링된 메시지를 별도의 파일에 넣으려면 다음과 같이 작성할 수 있습니다.

# 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

불행하게도 rsyslog는 커널 모듈 이름별 정확한 필터링을 지원하지 않지만 다른 속성을 시도해 볼 수 있습니다(MSG그 중 하나) 규칙을 사용하면 필터링 규칙을 보다 정확하게 지정할 수 있습니다》에 의해. . 시작","같다" 또는"정규식". 속성 및 규칙의 전체 목록은 다음과 같습니다.여기(아래를 내려다본다)사용 가능한 속성".
따라서 다음과 같이 시도해야 합니다.

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

또는:

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

어떤 속성에 커널 모드가 포함되어 있는지 모르겠습니다. 어쨌든 언제든지 필터링할 수 있습니다.MSG그리고정규식.

:msg, regex, "^write-regex-matching-your-module-log-output" :omfile:/var/log/mlan.log

관련 정보