1
votes

Where is Container-Optimized OS’s syslog file located? I’m looking for something like /var/log/syslog. One reason I need this is to troubleshoot ssh login failures.

2
You will need to use journalctl command - John Hanley
@JohnHanley – Care to be more specific? - Quinn Comendant
The syslogs are not located anywhere in the file system. They are sent to Stackdriver. If you want to see what is available inside the machine, you can use journalctl or go to Stackdriver and look at the logs. - John Hanley
sudo journalctl -ef shows logs from sshd, it's exactly what I needed. @JohnHanley, if you want to create an answer to this question, I'll mark it as correct. - Quinn Comendant
@JohnHanley BTW, I tried to view logs from this instance in Stackdriver, but there are none. I assumed it's because the agent isn't installed, but following the installation instructions failed with error, "Unidentifiable or unsupported platform". - Quinn Comendant

2 Answers

6
votes

Where is Container-Optimized OS’s syslog file located?

Container-Optimized OS uses systemd-journald to manage system logs, instead of any other syslog daemon (such as rsyslog).

You can see the documentation for systemd-journald at here: https://wiki.archlinux.org/index.php/Systemd/Journal

And long story short, you can view the logs via running command such as:

sudo journalctl
sudo journalctl -u sshd

One reason I need this is to troubleshoot ssh login failures.

If you have trouble establishing any SSH connection at all, running commands won't be a feasible solution. In that case, GCE serial console logs would be the closest tool: https://cloud.google.com/compute/docs/instances/viewing-serial-port-output

Stackdriver is built into Container OS. cloud.google.com/container-optimized-os/docs/release-notes

Here is the source code for the Stackdriver Logging on COS. You can start it via:

sudo systemctl start stackdriver-logging
2
votes

Where is Container-Optimized OS’s syslog file located?

The logfiles for Container OS are not stored on the container. Instead, the logs are sent to Stackdriver. Containers are designed to be destroyed and recreated. Storing logfiles on the container would mean loosing them.

To view the logs that do exist temporarily, as in the latest logs, you can use the program journalctl to view them.

Here is a link to an article that introduces journalctl and how to use the basic features:

Use journalctl to View Your System's Logs