Localhost shown in /var/log/* after reboot

Good Evening,
When building a new server and loading Rocky 9.1, I notice when booting up most notifications in /var/log/* files will say “localhost”. Once I log in, I can run a “systemctl restart rsyslog” and the “hostname” will now be in the logs. Is this a bug or something I missed in configuration?

Thank you,
T

The hostname can be “transient” or “static”. See man hostnamectl

How do you configure the network? The default is “auto”, with DHCP.

If static hostname was not set in installer, then machine boots as “localhost”
and sets the DNS-name of the IP address given by DHCP as transient hostname.
It can take a while before network is up and name is available, but it should not require
restart of logger services.

I do set static name only on “multi-homed” servers, where a service depends on the name.

Besides, the primary logger is systemd-journald. It can be configured to save logs to files.
The rsyslog is thus somewhat redundant service.

I tried both DHCP (which is normal) and even tried static but had same issue. 1/2 the log information has the hostname, half has localhost. Once I restart rsyslog, all entries are good. Tried this 8 times, 4 with static (IP/hostname) and 4 with DHCP. hostnamectl and hostname command showed the proper hostname/FQDN each time. 2 times for each set of four I waited 5 minutes and 10 minutes before I restarted rsyslog.

Did you set the hostname at the bottom of the Networking tab during the Rocky installer?

We are using KS file and then ansible roles to provision. I just ended up putting hostname into /etc/hostname right before we modified and restarted rsyslog. Kind of stuck on the KS file I have to use.

The network in kickstart does have parameter --hostname. See Appendix B. Kickstart commands and options reference Red Hat Enterprise Linux 9 | Red Hat Customer Portal

Thank you. I put that forward already to have that added to our kickstart, trying to remember how to make is see the DHCP name and make it static, Thought there was another variable to include FQDN. --hostname takes shortname I think.