by far the most common problem that correlates with rsyslog working when run manually, but not when run as a service is SELinux config. The SELinux context is different when you run something manually than when it's run as a service, and that can cause permission failures.

Check your SELinux logs for such failures.

David Lang

On Sun, 3 Jul 2016, Dr. Yury Zhauniarovich wrote:

Date: Sun, 3 Jul 2016 16:48:49 +0000
From: Dr. Yury Zhauniarovich <[email protected]>
Reply-To: rsyslog-users <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [rsyslog] Strange behavior of rsyslog, once it is run as a service

Dear rsyslog users,

I would like to ask you about strange behavior of rsyslog that I observe. I run 
CentOS 7.2 and I
have installed rsyslog 8.19.0 from official repository on it. My configuration 
assumes that I
collect logs from an application (that are stored in file in a separate folder) 
and send them to
kafka (using omkafka plugin) through a configured reverse ssh tunnel.

When I run syslog in debug mode (using `rsyslogd -dn > logfile` command), 
everything is working
fine. However, if I run a rsyslog systemd service (`systemctl start 
rsyslog.server`), I do not see
any output on my kafka.

I desperately need your help because it seems that I'm loosing my mind. Please, 
help! Any advice is
appreciated and thank you in advance!

Here is the content of rsyslog.service:

[Unit]
Description=System Logging Service
;Requires=syslog.socket
Documentation=man:rsyslogd(8)
Documentation=http://www.rsyslog.com/doc/

[Service]
Type=notify
ExecStart=/sbin/rsyslogd -n
StandardOutput=null
Restart=on-failure
UMask=0066 #I tried to also comment this line, no effect

[Install]
WantedBy=multi-user.target
;Alias=syslog.service




My rsyslog configuration file (basically, I did not change anything here):

#### GLOBAL DIRECTIVES ####

# Use default timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

# File syncing capability is disabled by default. This feature is usually not 
required,
# not useful and an extreme performance hit
#$ActionFileEnableSync on

# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf


#### RULES ####

# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.*                                                 /dev/console

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none                /var/log/messages

# The authpriv file has restricted access.
authpriv.*                                              /var/log/secure

# Log all the mail messages in one place.
mail.*                                                  /var/log/maillog


# Log cron stuff
cron.*                                                  /var/log/cron

# Everybody gets emergency messages
*.emerg                                                 :omusrmsg:*

# Save news errors of level crit and higher in a special file.
uucp,news.crit                                          /var/log/spooler

# Save boot messages also to boot.log
local7.*                                                /var/log/boot.log


# ### begin forwarding rule ###
# The statement between the begin ... end define a SINGLE forwarding
# rule. They belong together, do NOT split them. If you create multiple
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.
#$WorkDirectory /var/lib/rsyslog # where to place spool files
#$ActionQueueFileName fwdRule1 # unique name prefix for spool files
#$ActionQueueMaxDiskSpace 1g   # 1gb space limit (use as much as possible)
#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
#$ActionQueueType LinkedList   # run asynchronously
#$ActionResumeRetryCount -1    # infinite retries if host is down
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
#*.* @@remote-host:514
# ### end of the forwarding rule ###




My application configuration file (I also commented listen.conf in 
/etc/rsyslog.d/ folder):
module(load="imfile")       #to tail files
module(load="omkafka")      #to send data to Kafka

template(name="msgf" type="list") {
   property(name="msg")
}

input(type="imfile"
    File="/app_folder/app_log*.log"                    #template to files to 
read from
    Ruleset="to_kafka"                          #ruleset to process this input
    Tag=""                                             #how to prefix the 
message
)


ruleset(name="to_kafka") {
   action(type="omkafka"                               #type of module to use
       topic="app-topic"                             #topic to write data to
       broker=["localhost:9092"]                      #kafka destination 
(host:port) so as we are
using reverse ssh we write to standard local port
       action.resumeRetryCount="-1"
       queue.type="LinkedList"                         #type of the queue
       queue.spoolDirectory="/var/lib/rsyslog"
       queue.filename="omkafkaq"                       #use this parameter to 
create disk-assisted
queue
       queue.workerThreads="1"                         #how many threads to use
       queue.dequeueBatchSize="1000"                   #how many messages to 
pick from queue
       queue.size="10000"                              #how many messages to 
store in memory queue:
the data is still in the file and rsyslog can stop tailing when the queue 
becomes full, and then
resume tailing
       template="msgf"
       confParam=["compression.codec=snappy",          #we use snappy 
compression because it is the
fastest now (before lz4 is implemented)
           "socket.timeout.ms=1000",
           "socket.keepalive.enable=true",
           "queue.buffering.max.messages=1000",
       ]
   )
}

_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to