1 .\" Copyright (c) 2004 Apple Computer
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of Apple Computer nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .Nd Apple System Log utility
62 .Fl c Ar process Op filter
65 is a command-line utility for a variety of tasks relating to the Apple System Log facility.
66 It provides mechanisms for sending and viewing log messages,
67 pruning the contents of the system's log message data store,
68 and for controlling the flow of log messages from client processes.
74 prints a usage message.
78 option is used send log messages to the
81 either locally or to a remote server if the
85 There are two main forms of the command.
88 option is used, then it must be followed by a list of keys and values.
89 A structured message will be sent to the server with the keys and values given as arguments.
90 If a key or a value has embedded white space, it must be enclosed in quotes.
94 option is not specified, then the rest of the command line is treated as the message text.
95 The text may be preceded by
97 to set the log level (priority) of the message.
98 Levels may be an integer value corresponding the the log levels specified in
102 or they may be a string.
103 String values are case insensitive, and should be one of:
129 only requires one or two leading characters for a level specification.
130 A single character suffices in most cases.
135 for Panic / Emergency, and
143 daemon receives messages from a variety of input sources.
144 Received messages are processed by a set of output modules,
145 each of which may act on messages in different ways.
147 Two of the standard modules filter messages using criteria like the sender and the priority level of the message,
148 and write copies of these messages to different output streams.
149 One module does this filtering and filing task using the configuration specified in the
152 The output files specified in that configuration may be examined by any file printing or editing utility,
155 .Dl cat /var/log/system.log
157 Another module saves messages in a data store, which may be searched using the
161 If invoked with no arguments,
163 simply prints all of the messages saved in the data store. If the
167 waits for new messages to be added to the data store.
168 Messages already in the store are ignored.
169 This usage is similar to watching a log file using, e.g.
171 .Dl tail -f /var/log/system.log
173 Messages are printed in a format similar to that used in the system.log file,
174 except that the message priority level is printed between angle-brackets.
178 option forces all time stamps to be printed using UTC.
179 This overrides printing of time stamps using the local time zone.
181 The output format may by changed by specifying the
186 may be one of the following:
188 .Bl -tag -width "xxxx"
192 daemon for system log files, e.g. /var/log/system.log.
194 Standard (default) format.
197 but includes the message priority level.
199 Prints the complete message structure.
200 Each key/value pair is enclosed in square brackets.
201 Embedded closing brackets and white space are escaped.
202 Time stamps are printed using UTC rather than being converted to the local time zone.
207 argument may also be a custom print format string.
208 A custom format should in most cases be enclosed in single quotes to prevent the shell from substituting
209 special characters and breaking at white space.
211 Custom format strings may include variables of the form
215 if the variable is not delimited by whitespace)
216 which will be expanded to the associated with the named key.
217 For example, the command:
219 .Dl syslog -F '$Time $Host $(Sender)[$(PID)]: $Message'
221 produces output similar to the
225 If no further command line options are specified,
227 displays all messages,
228 either all those saved in the data store,
229 or all new messages if
232 However, an expression may be specified using the
238 Expressions specify matching criteria.
239 They may be used when reading messages to filter for messages of interest.
240 Expressions are also required when pruning the system log file with the
244 A simple expression is a list of one or more key/value pairs.
245 A match is made when a message has the given value for the specified key.
246 For example, to find all messages send by the portmap process:
248 .Dl syslog -k Sender portmap
252 option may be followed by one, two, or three arguments.
253 A single argument causes a match to occur if a message has the specified key, regardless of value.
254 If a pair of arguments is specified, a match occurs when a message has exactly the specified value for a given key.
255 If three arguments are given, they are of the form
256 .Fl k Ar key operation value .
258 supports the following matching operators:
260 .Bl -tag -width "xxx" -compact
268 greater than or equal to
272 less than or equal to
275 Additionally, the operator may be preceded by one or more of the following modifiers:
277 .Bl -tag -width "xxx" -compact
281 regular expression (see
293 An simple expression matches a message if all of the key-value operations match.
294 Logically, the result is an AND of all of key-value operations.
297 option separates simple expressions and provides an OR operation.
298 If two or more simple expressions are given, separated by
300 options, then a match occurs is a message matches any of the simple expressions.
301 For example, to find all messages which have either a
305 or that have a numeric priority level of 4 or less:
307 .Dl syslog -k Sender portmap -o -k Level Nle 4
309 A special convention exists for matching time stamps.
310 An unsigned integer value is regarded as the given number of seconds since
311 0 hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated Universal Time.
312 An negative integer value is regarded as the given number of seconds before the current time.
313 For example, to find all messages of priority level 3 (error) or less which were logged in the last 30 seconds:
315 .Dl syslog -k Level Nle 3 -k Time ge -30
317 a relative time value may be optionally followed by one of the characters
324 to specify seconds, minutes, hours, days, or weeks respectively.
325 Upper case may be used equivalently.
326 A week is taken to be 7 complete days (i.e. 604800 seconds).
328 The Apple System Log facility saves received messages, subject to filtering criteria described in the
329 FILTERING CONTROLS section below.
330 Pruning is required to prevent unlimited growth of the data store.
334 daemon itself will prune the data store shortly after it starts up.
337 manual for more details on startup pruning.
338 During extended operation of
340 pruning is accomplished by using the
346 option must be followed by an expression (see above).
347 The contents of the data store are filtered using the given expression.
348 Messages that match the expression are deleted.
350 A daily pruning operation is performed by the
353 The command is specified in the /etc/periodic/daily/500.daily file.
354 .Ss FILTERING CONTROLS
355 Clients of the Apple System Log facility using either the
359 interfaces may specify a log filter mask.
360 The mask specifies which messages should be sent to the
362 daemon by specifying a yes/no setting for each priority level.
363 Many clients set a filter mask to avoid sending relatively unimportant messages.
364 Debug or Info priority level messages are generally only useful for debugging operations.
365 By setting a filter mask, a process can improve performance by avoiding spending
366 time sending messages that are in most cases unnecessary.
370 option may be used to control filtering.
371 In addition to the internal filter value that processes may set as described above,
372 the system maintains a global
375 This filter is normally
377 meaning that it has no effect.
378 If a value is set for the master filter, it overrides the local filter for all processes.
379 Root user access is required to set the master filter value.
381 The current setting of the master filter mask may be inspected using:
385 The value of the master filter mask my be set by providing a second argument following
387 The value may a set of characters from the set
389 These correspond to the priority levels Emergency (Panic), Alert, Critical, Error, Warning, Notice, Info, and Debug.
392 may be used for Error, as it is used for sending messages.
393 The master filter may be unset with:
397 Since it is common to use the filter as a
399 mechanism, for example to cut off messages with Debug and Info priority,
400 a single character from the list above may be specified, preceded by a minus sign.
403 uses a filter mask starting at level 0 (Emergency)
406 For example, to set the master filter level to cause all processes to log messages from Emergency up to Debug:
410 While the master filter level may be set to control the messages produced by all processes,
411 another filter mask may be specified for an individual process.
412 If a per-process filter mask is set, it overrides both the local filter mask and the master filter mask.
413 The current setting for a per-process filter mask may be inspected using
417 is either a PID or the name of a process.
418 If a name is used, it must uniquely identify a process.
419 To set a per-process filter mask, an second argument may be supplied following
421 as described above for the master filter mask.
422 Root access is required to set the per-process filter mask for system (UID 0) processes.
424 The filtering described above takes place in the client library to determine which messages are sent to the
427 The daemon also contains a filter which determines which messages are saved in the data store.
428 Note that this additionally determines which messages are seen when reading messages using the
432 The default data store filter mask saves messages with priority levels from Emergency to Notice (level 0 to 5).
433 The level may be inspected using:
435 .Dl syslog -c syslogd
437 To set the data store filter mask, an second argument may be supplied following
440 For example, to save messages with priority level Error or less in the data store:
442 .Dl syslog -c syslog -e
451 utility appeared in Mac OS X 10.4.