I have written a python application which writes messages via rsyslog. I have configured rsyslog to write to a custom log file at /var/log/my_custom_log.log
where my entries are coming up fine.
My default syslog.conf
is unmodified. My /etc/rsyslog.d/00-myrules.conf
is as follows:
:msg, contains, "Transmission" /var/log/transmission.log
& ~
I also don't understand what the & ~ at the end does, but it seems to not work without it.
All I want is to be able to write logs to /home/me/logs/my_tests.log
. When I am testing my application, I need to ensure certain things are being written to the log a certain number of times. What I was doing before was writing my messages to a plain text file in my home directory, checking to see if this file was correct, then deleting it for each and every test. I now need to do the same thing but with rsyslog. I am running my tests as my user.
I want the normal logs to write to /var/log/my_app_log.log
, that's fine.
ps aux | grep "rsyslog"
, it returns that /usr/sbin/rsyslogd -n
is running under root, which (correct me if I'm wrong here) should be able to write to subdirectories my home directory, regardless of who owns it. РЕДАКТИРОВАТЬ : После дальнейшего обсуждения мы решили, что было бы глупо иметь журналы вне / var / log
. В конце концов, это то, для чего он нужен.
С помощью справки я обнаружил, что запуск ls -Z
раскрывает контексты SELinux. Как предлагалось на плакате, я скопировал контекст из / var / logs
в свой каталог журналов в моем доме, и я получаю желаемые результаты.
Однако я понимаю, что это не идеально, как описано принятым ответом в первом связанном вопросе, поскольку он не является пуленепробиваемым / долговечным. К сожалению, я недостаточно разбираюсь в SELinux, чтобы подробно остановиться на этом, и используемый метод будет работать в моей небольшой среде.