Bug 684152

Summary: RFE: systemd should connect SysV serivce output with syslog by default
Product: [Fedora] Fedora Reporter: Jóhann B. Guðmundsson <johannbg>
Component: systemdAssignee: Lennart Poettering <lpoetter>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 15CC: johannbg, k.georgiou, lpoetter, metherid, mschmidt, notting, plautrba
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-10-07 17:49:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jóhann B. Guðmundsson 2011-03-11 10:23:48 UTC
Description of problem:

This got mentioned on devel channel last night but apparently did not make it here so I a ran a series of test to confirm this.

Some service support syntax checking on startup restart reload etc.

When starting a service that has a misconfiguration failed error msg that contained why the service failed to start gets lost. 

Note that the error msg is outputted to the terminal and is not sent to any log file.

For example let's use httpd 

I added Test to the top of httpd.conf and tested the behaviour on F14 and F15 with httpd -t -k start, service httpd start ( for previous behaviour ) systemctl start httpd.service for current behaviour 

On F14

Test 1  

# httpd -t -k start
Syntax error on line 1 of /etc/httpd/conf/httpd.conf:
Invalid command 'Test', perhaps misspelled or defined by a module not included in the server configuration

Test 2

# service httpd start
Starting httpd: Syntax error on line 1 of /etc/httpd/conf/httpd.conf:
Invalid command 'Test', perhaps misspelled or defined by a module not included in the server configuration

                                                           [FAILED]
on F15

Test 1

# httpd -t -k start
Syntax error on line 1 of /etc/httpd/conf/httpd.conf:
Invalid command 'Test', perhaps misspelled or defined by a module not included in the server configuration

Test 2 

]# systemctl start httpd.service 
Job failed. See system logs and 'systemctl status' for details.

No logs contain the error msg nor does systemctl status. 

Version-Release number of selected component (if applicable):

systemd-units-20-1.fc15.i686
systemd-20-1.fc15.i686

How reproducible:

Always

Steps to Reproduce:
1. Trigger a syntax error when starting a service which support syntax checking
2.
3.
  
Actual results:

The above

Expected results:

The error being shown directly in when service was started from cli or when systemctl status was ran

Additional info:

Users expect "OK" or equivalent when service get started/restart/reloaded and a verbose output which contain why they failed to start when they do hence it might be best to default to show the output of "status" of a service when it gets started/reloaded/restart/stopped and omit -s to silence it for a less verbose output.

Comment 1 Bill Nottingham 2011-05-10 21:26:12 UTC
This can be done by editing /etc/systemd/system.conf as follows:

DefaultStandardOutput=syslog
DefaultStandardError=syslog

or via systemd.default_standard_output=, systemd.default_standard_error= on the boot command line.

(syslog+console is also accepted, but is probably a bad idea.)

Comment 2 Lennart Poettering 2011-05-10 22:36:07 UTC
You must be very careful with that since this might trigger a loop when you this way connect stdout/stderr of your syslog daemon with syslog.

In F16 we plan to make DefaultStandardOutput=syslog the default, since at that point we will mandate that all syslog implementations *must* use native unit files, which override the default explicitly (which you cannot do with SysV). Since all sysloggers nowadays are patched this should not be a problem.

Comment 3 Jóhann B. Guðmundsson 2011-05-10 22:45:09 UTC
(In reply to comment #1)
> This can be done by editing /etc/systemd/system.conf as follows:
> 
> DefaultStandardOutput=syslog
> DefaultStandardError=syslog
> 
> or via systemd.default_standard_output=, systemd.default_standard_error= on the
> boot command line.
> 
> (syslog+console is also accepted, but is probably a bad idea.)

This could be solved in the best way if systemd defaulted to ouput the status of a service when it gets manually started as in as opposed to show you nothing..

# systemctl start sshd.service

It would show you this.. 

# systemctl start sshd.service

sshd.service - OpenSSH server daemon.
	  Loaded: loaded (/lib/systemd/system/sshd.service)
	  Active: active (running) since Tue, 10 May 2011 22:27:01 +0000; 5s ago
	 Process: 6478 ExecStart=/usr/sbin/sshd $OPTIONS (code=exited, status=0/SUCCESS)
	 Process: 6476 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
	Main PID: 6479 (sshd)
	  CGroup: name=systemd:/system/sshd.service
		  └ 6479 /usr/sbin/sshd

Or this if it failed which btw is much more meaningful than 
"Job failed. See system logs and 'systemctl status' for details.

# systemctl start sshd.service

sshd.service - OpenSSH server daemon.
	  Loaded: loaded (/lib/systemd/system/sshd.service)
	  Active: failed since Tue, 10 May 2011 22:27:40 +0000; 20s ago
	 Process: 6478 ExecStart=/usr/sbin/sshd $OPTIONS (code=exited, status=0/SUCCESS)
	 Process: 6488 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=255)
	Main PID: 6479 (code=exited, status=255)
	  CGroup: name=systemd:/system/sshd.service

Admins are forced to run systemst status afterwards or start tailing logs or as you propose change conf file to get the output that was previously presented to them with [OK] or [Failed] ( sometimes with syntax error pointing to the line if syntax checking was supported ). 

That's an significant step backwards for admins from my pov...

Comment 4 Michal Schmidt 2011-10-07 17:49:49 UTC
In F16 we are setting "DefaultStandardOutput=syslog" in the default configuration.