Write rsyslog log to home

What I Currently Have Working

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.

What I Need To Work

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.

What I Have Tried

  1. This user seems to have had the same issue I am, but I am not understanding either the accepted answer (I don't understand what SElinux has to do with it, how it may be influencing anything, or what or where these labels are that they are talking about), or the other one (the user mentions doing something not recommended for security reasons, which I should avoid but I don't understand where to run this command even if I wanted to).
  2. This user's issue turned out to be a matter of who owned the directory, but if I run 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.
0
задан 17 August 2017 в 22:09
1 ответ

РЕДАКТИРОВАТЬ : После дальнейшего обсуждения мы решили, что было бы глупо иметь журналы вне / var / log . В конце концов, это то, для чего он нужен.

С помощью справки я обнаружил, что запуск ls -Z раскрывает контексты SELinux. Как предлагалось на плакате, я скопировал контекст из / var / logs в свой каталог журналов в моем доме, и я получаю желаемые результаты.

Однако я понимаю, что это не идеально, как описано принятым ответом в первом связанном вопросе, поскольку он не является пуленепробиваемым / долговечным. К сожалению, я недостаточно разбираюсь в SELinux, чтобы подробно остановиться на этом, и используемый метод будет работать в моей небольшой среде.

0
ответ дан 5 December 2019 в 07:31

Теги

Похожие вопросы