Docker CentOS Installation Syslog

Source: Internet
Author: User
Tags syslog docker centos rsyslog

In a typical Linux server, some services themselves do not have logs and can only be viewed by tail-f/var/log/messages to view their run logs, such as Nrpe server. However, if you want to implement this functionality in a Docker container, it will take a bit of work. The steps are as follows:

1, installation Rsyslog

Yum Install Rsyslog

2. Start the Syslog service

# RSYSLOGD


3. Test whether the log is generated in messages

" Hello World "


It turns out that there is only one line in messages: "1 11:31:37 f2570fed2149 rsyslogd: [Origin software=" Rsyslogd "swversion=" 7.4.7 "x-pid=" 73 " x-info= "http://www.rsyslog.com" "Start", it can be determined that it does not work. The reason is: "The problem was, RHEL7 and Fedora We are use Journald, which listens on/dev/log for incoming messages. In RHEL7 and Fedora, Rsyslog actually reads messages from the journal via its API by default.But the all Docker containers run Systemd and Journald. (most don ' t). In order to get the rsyslogd-to-work the the the user wanted, he would has to modify the configuration file, /etc/rsyslog.conf ”。

The solution is as follows:

1. Modify the syslog configuration--# vi/etc/rsyslog.conf

12, set $OmitLocalLogging to Off3, commented out $IMJournalStateFile imjournal.state

2. Submit container to mirror, re-create container

[[email protected] home]# Docker commit f2570fed2149 centos_with_syslog:v1. 0  223:222 -v/dev/log:/dev/log-ti centos_with_syslog:v1. 0 /run. SH dc2eb83e80ced6f553eb1dd7032489d37b4d934a9126f61dfbd4d6a2243e98f1


3. Test verification

[email protected] home]# Docker Exec-ti dc2eb83e80ced6f553eb1dd7032489d37b4d934a9126f61dfbd4d6a2243e98f1/bin/Bash[[email protected]/]# Logger"Hello everyone"[[Email protected]/]# exitexit[[email protected] home]#Tail-f/var/log/messages (note View Log in messages file on host)1  +: $:Wuyilocalhost Docker: Time="2015-08-01t19:57:51+08:00"Level=Infomsg="-job log (exec_start:/bin/bash, DC2EB83E80CED6F553EB1DD7032489D37B4D934A9126F61DFBD4D6A2243E98F1, Centos_with_ syslog:v1.0) = OK (0)" the1  +: $:Wuyilocalhost Docker: Time="2015-08-01t19:57:51+08:00"Level=Infomsg="post/v1.18/exec/9ae97d0666bf5abcd8d95eb87d10c5d013a0f006c2cb1adc7ff8f7baaacf14fc/resize?h=37&w=191 " the1  +: $:Wuyilocalhost Docker: Time="2015-08-01t19:57:51+08:00"Level=Infomsg="+job execresize (9AE97D0666BF5ABCD8D95EB87D10C5D013A0F006C2CB1ADC7FF8F7BAAACF14FC, Notoginseng, 191)" the1  +: $:Wuyilocalhost Docker: Time="2015-08-01t19:57:51+08:00"Level=Infomsg="-job execresize (9AE97D0666BF5ABCD8D95EB87D10C5D013A0F006C2CB1ADC7FF8F7BAAACF14FC, Notoginseng, 191) = OK (0)" the1  +: -: thelocalhost logger:Hello everyone

Docker CentOS Installation Syslog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.