On Wed, 2007-02-21 at 19:22 -0700, Jason J. W. Williams wrote:
> Hi Bob,
> 
> Sorry to bother. How should one echo an informational message so it
> gets captured to the SMF log for the service?

No bother at all :-)

Way at the bottom of the smf_method man page it says something like


File descriptors  File  descriptor  0  is  /dev/null.   File
                       descriptors  1 and 2 are recommended to be
                       a per-service log file.



So if you just write to stdout or stderr (or shell echo) it will go
in the service log file, which by default
is /var/svc/log/<munging-up-of-service-name-to-remove-/'s>.log.


In my example using MySQL (see
http://bloghttp://blogs.sun.com/bobn/entry/manifests_for_apache1_and_mysql )

I added an echo "Hello World..." to the start method.   Looking in the
logs I see


# tail -f /var/svc/log/application-mysql:default.log
[ Feb 21 21:53:02 Reading configuration. ]
[ Feb 21 21:53:02 No 'refresh' method defined.  Treating as :true. ]
[ Feb 21 21:53:32 Stopping because service restarting. ]
[ Feb 21 21:53:32 Executing stop method ("/etc/sfw/mysql/mysql.server
stop") ]
Hello World...
Killing mysqld with pid 1411
Wait for mysqld to exit. done
[ Feb 21 21:53:35 Method "stop" exited with status 0 ]
[ Feb 21 21:53:35 Executing start method ("/etc/sfw/mysql/mysql.server
start") ]
Hello World...
[ Feb 21 21:53:35 Method "start" exited with status 0 ]


So unless you have a delegated restarter that is doing something funky
like eating stdout and stderr then a simple echo should do.


Bob


Reply via email to