Depending on your needs, syslogd might be another tool to peruse. The command
theuser@tetrad:~$ logger This message is sent to syslog
will log the message with the facility user.notice. With many Linux systems this will be enough to have a file /var/log/user.log opened and appended to, with others you may need to define a handling for that facility and log level (or, whichever facility you choose - the local0 to local7 facilities are usually free to assign to things like this.
It's got the benefit of being able (aka configurable) to send notes from client machines to a central logging server, something I like to use for keeping track of administrative action since it preserves timestamp, user and host information automagically, while keeping actions in order.
resulting output in local file:
theuser@tetrad:~$ tail /var/log/user.log
Jan 31 07:18:37 tetrad theuser: This message is sent to syslog
Example for syslog configuration line on Solaris:
local5.notice ifdef(`LOGHOST', /var/log/diary, @loghost)
ifdef is preprocessed with
m4, on the machine with the hostname/hostalias "loghost", the messages will be logged to the file /var/log/diary, on all others, they will be sent to the remote syslog service at loghost. To test this kind of configuration, the config file can be sent through m4 for expansion (leave away the
-D LOGHOST to see how it would look on a system not called loghost:
theuser@solstice$ /usr/ccs/bin/m4 -D LOGHOST /etc/syslog.conf