I wrote a simple test application to log something in a log file. I am using linux mint and after the application executes I try to view the log using this command: <
I'm running Ubuntu under WSL(Windows Subsystem for Linux) and systemctl start rsyslog
didn't work for me.
So what I did is this:
$ service rsyslog start
Now syslog
file will appear at /var/log/
Logging is very configurable in Linux, and you might want to look into your /etc/syslog.conf
(or perhaps under /etc/rsyslog.d/
). Details depend upon the logging subsystem, and the distribution.
Look also into files under /var/log/
(and perhaps run dmesg
for kernel logs).
syslog() generates a log message, which will be distributed by syslogd.
The file to configure syslogd is /etc/syslog.conf. This file will tell your where the messages are logged.
How to change options in this file ? Here you go http://www.bo.infn.it/alice/alice-doc/mll-doc/duix/admgde/node74.html
You have to tell the system what information to log and where to put the info. Logging is configured in the /etc/rsyslog.conf
file, then restart rsyslog to load the new config. The default logging rules are usually in a /etc/rsyslog.d/50-default.conf
file.
On my Ubuntu machine, I can see the output at /var/log/syslog
.
On a RHEL/CentOS machine, the output is found in /var/log/messages
.
This is controlled by the rsyslog
service, so if this is disabled for some reason you may need to start it with systemctl start rsyslog
.
As noted by others, your syslog()
output would be logged by the /var/log/syslog
file.
You can see system, user, and other logs at /var/log
.
For more details: here's an interesting link.
Default log location (rhel) are
General messages:
/var/log/messages
Authentication messages:
/var/log/secure
Mail events:
/var/log/maillog
Check your /etc/syslog.conf
or /etc/syslog-ng.conf
(it depends on which of syslog facility you have installed)
Example:
$ cat /etc/syslog.conf
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.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
#For a start, use this simplified approach.
*.* /var/log/messages