0

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

EDIT: After further discussion, we have decided that it was silly to have logs outside of /var/log. That's what it's there for, after all.

With this post's help, I have found that running ls -Z reveals the SELinux contexts. As the poster suggested, I copied the context from /var/logs to my log directory in my home, and I am getting the desired results.

However, I realize that this is not ideal as described by the accepted answer in the first linked question, as it is not bulletproof/timeproof. Unfortunately, I do not understand SELinux enough to properly elaborate on this, and the method used will work for my small environment.

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.