]>
Commit | Line | Data |
---|---|---|
db78b1bd | 1 | .\"Copyright (c) 2004-2011 Apple Inc. All rights reserved. |
b16a592a | 2 | .\" |
57b0aad2 | 3 | .\"@APPLE_LICENSE_HEADER_START@ |
b16a592a | 4 | .\" |
57b0aad2 A |
5 | .\"This file contains Original Code and/or Modifications of Original Code |
6 | .\"as defined in and that are subject to the Apple Public Source License | |
7 | .\"Version 2.0 (the 'License'). You may not use this file except in | |
8 | .\"compliance with the License. Please obtain a copy of the License at | |
9 | .\"http://www.opensource.apple.com/apsl/ and read it before using this | |
10 | .\"file. | |
b16a592a | 11 | .\" |
57b0aad2 A |
12 | .\"The Original Code and all software distributed under the License are |
13 | .\"distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
14 | .\"EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
15 | .\"INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
16 | .\"FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
17 | .\"Please see the License for the specific language governing rights and | |
18 | .\"limitations under the License. | |
19 | .\" | |
20 | .\"@APPLE_LICENSE_HEADER_END@ | |
b16a592a A |
21 | .\" |
22 | .Dd October 18, 2004 | |
23 | .Dt SYSLOG 1 | |
24 | .Os "Mac OS X" | |
25 | .Sh NAME | |
26 | .Nm syslog | |
27 | .Nd Apple System Log utility | |
28 | .Sh SYNOPSIS | |
29 | .Nm | |
30 | .Fl help | |
31 | .D1 "" | |
32 | .Nm | |
33 | .Fl s | |
34 | .Op Fl r Ar host | |
35 | .Op Fl l Ar level | |
36 | message... | |
37 | .D1 "" | |
38 | .Nm | |
39 | .Fl s | |
40 | .Op Fl r Ar host | |
41 | .Fl k | |
42 | key val | |
43 | .Op key val | |
44 | .Li ... | |
45 | .D1 "" | |
46 | .Nm | |
5dd30d76 A |
47 | .Fl C |
48 | .D1 "" | |
49 | .Nm | |
57b0aad2 A |
50 | .Op Fl f Ar file ... |
51 | .Op Fl d Ar dir ... | |
a83ff38a | 52 | .Op Fl B |
5dd30d76 | 53 | .Op Fl w Op Ar n |
b16a592a | 54 | .Op Fl F Ar format |
5dd30d76 | 55 | .Op Fl T Ar format |
57b0aad2 | 56 | .Op Fl E Ar format |
b16a592a A |
57 | .Ar expression |
58 | .D1 "" | |
59 | .Nm | |
57b0aad2 A |
60 | .Op Fl f Ar file ... |
61 | .Op Fl d Ar dir ... | |
62 | .Fl x Ar file Ar expression | |
b16a592a A |
63 | .D1 "" |
64 | .Nm | |
65 | .Fl c Ar process Op filter | |
db78b1bd A |
66 | .D1 "" |
67 | .Nm | |
68 | .Fl config Op options | |
b16a592a A |
69 | .Sh DESCRIPTION |
70 | .Nm | |
57b0aad2 | 71 | is a command-line utility for a variety of tasks relating to the Apple System Log (ASL) facility. |
b16a592a | 72 | It provides mechanisms for sending and viewing log messages, |
57b0aad2 | 73 | copying log messages to ASL format data store files, |
b16a592a A |
74 | and for controlling the flow of log messages from client processes. |
75 | .Pp | |
76 | When invoked with the | |
77 | .Fl help | |
78 | option, | |
79 | .Nm | |
80 | prints a usage message. | |
81 | .Ss SENDING MESSAGES | |
82 | The | |
83 | .Fl s | |
84 | option is used send log messages to the | |
85 | .Xr syslogd 8 | |
86 | log message daemon, | |
87 | either locally or to a remote server if the | |
88 | .Fl r Ar host | |
89 | option in used. | |
90 | .Pp | |
91 | There are two main forms of the command. | |
92 | If the | |
93 | .Fl k | |
94 | option is used, then it must be followed by a list of keys and values. | |
95 | A structured message will be sent to the server with the keys and values given as arguments. | |
96 | If a key or a value has embedded white space, it must be enclosed in quotes. | |
97 | .Pp | |
57b0aad2 A |
98 | Note that the text of the log message should be supplied as a value following the |
99 | .Dq Message | |
100 | key. | |
101 | .Pp | |
b16a592a A |
102 | If the |
103 | .Fl k | |
104 | option is not specified, then the rest of the command line is treated as the message text. | |
105 | The text may be preceded by | |
106 | .Fl l Ar level | |
107 | to set the log level (priority) of the message. | |
108 | Levels may be an integer value corresponding the the log levels specified in | |
109 | .Xr syslog 3 | |
110 | or | |
111 | .Xr asl 3 , | |
112 | or they may be a string. | |
113 | String values are case insensitive, and should be one of: | |
114 | .Pp | |
115 | .Bl -tag -compact | |
116 | .It Emergency | |
117 | (level 0) | |
118 | .It Alert | |
119 | (level 1) | |
120 | .It Critical | |
121 | (level 2) | |
122 | .It Error | |
123 | (level 3) | |
124 | .It Warning | |
125 | (level 4) | |
126 | .It Notice | |
127 | (level 5) | |
128 | .It Info | |
129 | (level 6) | |
130 | .It Debug | |
131 | (level 7) | |
132 | .El | |
133 | .Pp | |
134 | The string | |
135 | .Dq Panic | |
136 | is an alias for | |
137 | .Dq Emergency . | |
5dd30d76 A |
138 | .Pp |
139 | If the | |
140 | .Fl l | |
141 | option is omitted, the log level defaults to 7 (Debug). | |
142 | .Pp | |
b16a592a A |
143 | .Nm |
144 | only requires one or two leading characters for a level specification. | |
145 | A single character suffices in most cases. | |
146 | Use | |
147 | .Dq P | |
148 | or | |
149 | .Dq \&Em | |
150 | for Panic / Emergency, and | |
151 | .Dq \&Er | |
152 | or | |
153 | .Dq X | |
154 | for Error). | |
155 | .Ss READING MESSAGES | |
156 | The | |
157 | .Nm syslogd | |
5dd30d76 A |
158 | daemon filters and saves log messages to different output streams. |
159 | One module saves messages to files specified in the | |
b16a592a A |
160 | .Xr syslog.conf 5 |
161 | file. | |
5dd30d76 | 162 | Those log files may be examined with any file printing or editing utility, |
b16a592a A |
163 | e.g. |
164 | .Pp | |
165 | .Dl cat /var/log/system.log | |
166 | .Pp | |
57b0aad2 | 167 | Another module saves messages in a data store (/var/log/asl). |
b16a592a A |
168 | .Pp |
169 | If invoked with no arguments, | |
170 | .Nm | |
db78b1bd | 171 | fetches all messages from the active data store. |
57b0aad2 A |
172 | Messages are then printed to standard output, |
173 | subject to formatting options and character encoding as described below. | |
174 | Some log messages are read-access controlled, | |
175 | so only messages that are readable by the user running | |
176 | .Nm | |
177 | will be fetched and printed. | |
5dd30d76 A |
178 | .Pp |
179 | If invoked with the | |
180 | .Fl C | |
181 | option, | |
182 | .Nm | |
183 | fetches and prints console messages. | |
184 | The | |
185 | .Fl C | |
186 | option is actually an alias for the expression: | |
187 | .Pp | |
188 | .Dl -k Facility com.apple.console | |
189 | .Pp | |
190 | See the EXPRESSIONS section below for more details. | |
191 | .Pp | |
57b0aad2 A |
192 | Individual ASL data store files may be read by providing one or more file names as arguments to the |
193 | .Fl f | |
194 | option. | |
195 | This may be useful when searching archived files, files on alternate disk volumes, | |
196 | or files created as export files with the | |
197 | .Fl x | |
198 | option. | |
199 | .Pp | |
200 | The | |
201 | .Fl d | |
202 | option may be followed by a list of directory paths. | |
5dd30d76 | 203 | .Nm |
57b0aad2 A |
204 | will read or search all ASL data store files in those directories. |
205 | Any files that are not readable will be skipped. | |
206 | Specifying | |
207 | .Fl d | |
208 | with the name | |
209 | .Dq archive | |
210 | will open all readable files in the default ASL archive directory /var/log/asl.archive. | |
211 | Specifying | |
212 | .Fl d | |
213 | with the name | |
214 | .Dq store | |
215 | will open all readable files in the ASL store directory /var/log/asl. | |
216 | .Pp | |
217 | Legacy ASL database files that were written by | |
5dd30d76 | 218 | .Nm syslogd |
57b0aad2 A |
219 | on Mac OS X 10.5 (Leopard) may also be read using the |
220 | .Fl f | |
5dd30d76 | 221 | option. |
57b0aad2 A |
222 | However only one such legacy database may be read or searched at a time. |
223 | Note that a legacy database may be read and copied into a new ASL data store format file using a combination of | |
224 | .Fl f | |
225 | and | |
226 | .Fl x | |
227 | options. | |
5dd30d76 A |
228 | .Pp |
229 | The | |
a83ff38a A |
230 | .Fl B |
231 | option causes | |
232 | .Nm | |
233 | to start processing messages beginning at the time of the last system startup. | |
234 | If used in conjunction with | |
235 | .Fl w , | |
236 | all messages since the last system startup are displayed, or matched against an expression, before | |
237 | .Nm | |
238 | waits for new messages. | |
239 | .Pp | |
240 | The | |
b16a592a | 241 | .Fl w |
5dd30d76 A |
242 | option causes |
243 | .Nm | |
244 | to wait for new messages. | |
245 | By default, | |
b16a592a | 246 | .Nm |
5dd30d76 | 247 | prints the last 10 messages, |
57b0aad2 | 248 | then waits for new messages to be added to the data store. |
5dd30d76 A |
249 | A number following the |
250 | .Fl w | |
251 | option specifies the number of messages to print and overrides the default value of 10. | |
252 | For example: | |
253 | .Pp | |
254 | .Dl syslog -w 20 | |
255 | .Pp | |
a83ff38a A |
256 | Use the value |
257 | .Dq all | |
258 | to view all messages in the data store before watching for new messages. | |
259 | The value | |
260 | .Dq boot | |
261 | will display messages since the last system startup before watching for new messages. | |
262 | Specifying | |
263 | .Dq -w boot | |
264 | is equivalent to using | |
265 | .Fl w | |
266 | and | |
267 | .Fl B | |
268 | together. | |
269 | .Pp | |
270 | Using | |
271 | .Nm | |
272 | with the | |
273 | .Fl w | |
274 | option is similar to watching a log file using, e.g. | |
b16a592a A |
275 | .Pp |
276 | .Dl tail -f /var/log/system.log | |
277 | .Pp | |
5dd30d76 A |
278 | The |
279 | .Fl w | |
57b0aad2 A |
280 | option can only be used when reading the system's ASL data store or when reading a single data store file, |
281 | and when printing messages to standard output. | |
b16a592a | 282 | .Pp |
5dd30d76 | 283 | If the |
57b0aad2 A |
284 | .Fl x Ar file |
285 | option is specified, messages are copied to the named file rather than being printed. | |
286 | The file will be created if it does not exist. | |
5dd30d76 A |
287 | .Pp |
288 | When called without the | |
289 | .Fl x | |
290 | option, messages are printed to standard output. | |
291 | Messages are printed in a format similar to that used in the system.log file, | |
292 | except that the message priority level is printed between angle-brackets. | |
b16a592a A |
293 | .Pp |
294 | The output format may by changed by specifying the | |
295 | .Fl F Ar format | |
296 | option. | |
57b0aad2 A |
297 | Non-printable and control characters are encoded by default. |
298 | Text encoding may be controlled using the | |
299 | .Fl E | |
300 | option (see below). | |
b16a592a A |
301 | The value of |
302 | .Ar format | |
303 | may be one of the following: | |
304 | .Pp | |
305 | .Bl -tag -width "xxxx" | |
306 | .It bsd | |
307 | Format used by the | |
308 | .Nm syslogd | |
309 | daemon for system log files, e.g. /var/log/system.log. | |
310 | .It std | |
311 | Standard (default) format. | |
312 | Similar to | |
313 | .Dq bsd , | |
314 | but includes the message priority level. | |
315 | .It raw | |
316 | Prints the complete message structure. | |
317 | Each key/value pair is enclosed in square brackets. | |
318 | Embedded closing brackets and white space are escaped. | |
5dd30d76 A |
319 | Time stamps are printed as seconds since the epoch by default, but may also be |
320 | printed in local time or UTC if the | |
321 | .Fl T | |
322 | option is specified (see below). | |
323 | .It xml | |
324 | The list of messages is printed as an XML property list. | |
325 | Each message is represented as a dictionary in a array. | |
326 | Dictionary keys represent message keys. | |
327 | Dictionary values are strings. | |
b16a592a A |
328 | .El |
329 | .Pp | |
330 | The value of the | |
331 | .Ar format | |
332 | argument may also be a custom print format string. | |
333 | A custom format should in most cases be enclosed in single quotes to prevent the shell from substituting | |
334 | special characters and breaking at white space. | |
335 | .Pp | |
336 | Custom format strings may include variables of the form | |
db78b1bd A |
337 | .Dq $Name , |
338 | .Dq $(Name) , | |
339 | or | |
340 | .Dq $((Name)(format)) . | |
341 | which will be expanded to the value associated with the named key. | |
b16a592a A |
342 | For example, the command: |
343 | .Pp | |
db78b1bd | 344 | .Dl syslog -F '$Time $Host $(Sender)[$(PID)] <$((Level)(str))>: $Message' |
b16a592a A |
345 | .Pp |
346 | produces output similar to the | |
db78b1bd | 347 | .Dq std |
b16a592a | 348 | format. |
db78b1bd A |
349 | The simple |
350 | .Dq $Name | |
351 | form is sufficient in most cases. | |
352 | However, the second form: | |
353 | .Dq $(Name) | |
354 | must be used if the name is not delimited by white space. | |
355 | The third form allows different formats of the value to be printed. | |
356 | For example, a message priority level may appear as an integer value (e.g. | |
357 | .Dq 3 ) | |
358 | or as a string (``Error''). | |
359 | The following print formats are known. | |
360 | .Pp | |
361 | .Bl -tag -width "$((Time)([+|-]HH[:MM]))" | |
362 | .It $((Level)(str)) | |
363 | Formats a Level value as a string, for example | |
364 | .Dq Error , | |
365 | .Dq Alert , | |
366 | .Dq Warning , | |
367 | and so on. | |
368 | Note that $(Level) or $Level formats the value as an integer 0 through 7. | |
369 | .It $((Time)(sec)) | |
370 | Formats a Time value as the number of seconds since the Epoch. | |
371 | .It $((Time)(raw)) | |
372 | Alias for $((Time)(sec)). | |
373 | .It $((Time)(local)) | |
374 | Formats a Time value as a string of the form | |
375 | .Dq "Mmm dd hh:mm:ss" , | |
376 | where Mmm is the abbreviation for the month, dd is the date (1 - 31) and hh:mm:ss is the time. | |
377 | The local timezone is used. | |
378 | .It $((Time)(lcl)) | |
379 | Alias for $((Time)(local)). | |
380 | .It $((Time)(utc)) | |
381 | Formats a Time value as a string of the form | |
382 | .Dq "yyyy-mm-dd hh:mm:ssZ" , | |
383 | using Coordinated Universal Time, or the | |
384 | .Dq Zulu | |
385 | time zone. | |
386 | .It $((Time)(zulu)) | |
387 | Alias for $((Time)(utc)). | |
388 | .It $((Time)(X)) | |
389 | Where X may be any letter in the range A - Z or a - z. | |
390 | Formats the Time using the format | |
391 | .Dq "yyyy-mm-dd hh:mm:ssX" , | |
392 | using the specified nautical timezone. | |
393 | Z is the same as UTC/Zulu time. Timezones A - M (except J) decrease by one hour to the east of the | |
394 | Zulu time zone. | |
395 | Timezones N - Y increase by one hour to the west of Z. | |
396 | M and Y have the same clock time, but differ by one day. | |
397 | J is used to indicate the local timezone. | |
398 | When printing using $((Time)(J)), the output format is | |
399 | .Dq "yyyy-mm-dd hh:mm:ss" , | |
400 | without a trailing timezone letter. | |
401 | .It $((Time)([+|-]HH[:MM])) | |
402 | Specifies an offset (+ or -) of the indicated number of hours (HH) and optionally minutes (MM) to UTC. | |
403 | The value is formatted as a string of the form | |
404 | .Dq "yyyy-mm-dd hh:mm:ss[+|-]HH:MM" . | |
405 | .El | |
b16a592a | 406 | .Pp |
db78b1bd A |
407 | If a custom format is not being used to specify the format for Time values, then Time values |
408 | are generally converted to local time, except when the | |
409 | .Fl F Ar raw | |
5dd30d76 A |
410 | option is used, in which case times are printed as the number of seconds since the epoch. |
411 | The | |
412 | .Fl T Ar format | |
db78b1bd | 413 | option may be used to control the format used for timestamps. |
5dd30d76 A |
414 | The value of |
415 | .Ar format | |
416 | may be one of the following: | |
417 | .Pp | |
db78b1bd A |
418 | .Bl -tag -width "local or lcl" |
419 | .It sec or raw | |
5dd30d76 | 420 | Times are printed as the number of seconds since the epoch. |
db78b1bd | 421 | .It local or lcl |
5dd30d76 | 422 | Times are converted to the local time zone, and printed with the format |
db78b1bd A |
423 | .Dl mmm dd hh:mm:ss |
424 | where mmm is the month name abbreviated as three characters. | |
425 | .It utc or zulu | |
5dd30d76 | 426 | Times are converted to UTC, and printed with the format |
db78b1bd A |
427 | .Dl yyyy-mm-dd hh:mm:ssZ |
428 | .It A-Z | |
429 | Times are converted to the indicated nautical time zone, | |
430 | printed in the same format as UTC. | |
431 | .Dq J | |
432 | is interpreted as the local timezone and printed in the same format, | |
433 | but without a trailing timezone letter. | |
434 | .It [+|-]hh[:mm] | |
435 | The specified offset is used to adjust time. | |
5dd30d76 A |
436 | .El |
437 | .Pp | |
438 | The | |
439 | .Fl u | |
440 | option is a short form for | |
441 | .Fl T Ar utc . | |
442 | .Pp | |
57b0aad2 A |
443 | By default, control characters and non-printable characters are encoded in the output stream. |
444 | In some cases this may make messages less natural in appearance. | |
445 | The encoding is designed to preserve all the information in the log message, | |
db78b1bd | 446 | and to prevent malicious users from spoofing or obscuring information in log messages. |
5dd30d76 | 447 | .Pp |
57b0aad2 | 448 | Text in the |
5dd30d76 A |
449 | .Dq std , |
450 | .Dq bsd , | |
451 | and | |
452 | .Dq raw | |
453 | formats is encoded as it is by the | |
57b0aad2 | 454 | .Nm vis |
5dd30d76 A |
455 | utility with the |
456 | .Fl c | |
457 | option. | |
458 | Newlines and tabs are also encoded as "\\n" and "\\t" respectively. | |
459 | In | |
460 | .Dq raw | |
57b0aad2 | 461 | format, space characters embedded in log message keys are encoded as "\\s" |
5dd30d76 A |
462 | and embedded brackets are escaped to print as "\\[" and "\\]". |
463 | .Pp | |
464 | XML format output requires that keys are valid UTF8 strings. | |
465 | Keys which are not valid UTF8 are ignored, and the associated value is not printed. | |
466 | .Pp | |
467 | Values that contain legal UTF8 are printed as strings. | |
468 | Ampersand, less than, greater than, quotation mark, and apostrophe characters are encoded according to XML conventions. | |
469 | Embedded control characters are encoded as | |
470 | .Dq &#xNN; | |
db78b1bd | 471 | where NN is the character's hexadecimal value. |
5dd30d76 A |
472 | .Pp |
473 | Values that do not contain legal UTF8 are encoded in base-64 and printed as data objects. | |
474 | .Pp | |
57b0aad2 A |
475 | The |
476 | .Fl E Ar format | |
db78b1bd | 477 | option may be used to explicitly control the text encoding. |
57b0aad2 A |
478 | The value of |
479 | .Ar format | |
480 | may be one of the following: | |
481 | .Pp | |
482 | .Bl -tag -width "safe" | |
483 | .It vis | |
484 | The default encoding described above. | |
485 | .It safe | |
486 | Encodes backspace characters as ^H. | |
487 | Carriage returns are mapped to newlines. | |
488 | A tab character is appended after newlines so that message text is indented. | |
489 | .It none | |
490 | No encoding is used. | |
491 | .El | |
492 | .Pp | |
493 | The intent of the | |
494 | .Dq safe | |
495 | encoding is to prevent obvious message spoofing or damage. | |
496 | The appearance of messages printed will depend on terminal settings and UTF-8 string handling. | |
497 | It is possible that messages printed using the | |
498 | .Dq safe | |
499 | or | |
500 | .Dq none | |
501 | options may be garbled or subject to manipulation through the use of control characters and control sequences | |
502 | embedded in user-supplied message text. | |
503 | The default | |
504 | .Dq vis | |
505 | encoding should be used to view messages if there is any suspicion | |
506 | that message text may have been used to manipulate the printed representation. | |
507 | .Pp | |
b16a592a A |
508 | If no further command line options are specified, |
509 | .Nm | |
57b0aad2 | 510 | displays all messages, or copies all messages to a data store file. |
b16a592a A |
511 | However, an expression may be specified using the |
512 | .Fl k | |
513 | and | |
514 | .Fl o | |
515 | options. | |
516 | .Ss EXPRESSIONS | |
517 | Expressions specify matching criteria. | |
5dd30d76 | 518 | They may be used to search for messages of interest. |
b16a592a | 519 | .Pp |
57b0aad2 A |
520 | A simple expression |
521 | has the form: | |
522 | .Pp | |
523 | .Dl -k key [[op] val] | |
524 | .Pp | |
525 | The | |
526 | .Fl k | |
527 | option may be followed by one, two, or three arguments. | |
528 | A single argument causes a match to occur if a message has the specified key, regardless of value. | |
529 | If two arguments are specified, a match occurs when a message has exactly the specified value for a given key. | |
5dd30d76 | 530 | For example, to find all messages sent by the portmap process: |
b16a592a A |
531 | .Pp |
532 | .Dl syslog -k Sender portmap | |
533 | .Pp | |
5dd30d76 A |
534 | Note that the |
535 | .Fl C | |
536 | option is treated as an alias for the expression: | |
537 | .Pp | |
538 | .Dl -k Facility com.apple.console | |
539 | .Pp | |
540 | This provides a quick way to search for console messages. | |
541 | .Pp | |
b16a592a A |
542 | If three arguments are given, they are of the form |
543 | .Fl k Ar key operation value . | |
544 | .Nm | |
545 | supports the following matching operators: | |
546 | .Pp | |
547 | .Bl -tag -width "xxx" -compact | |
548 | .It eq | |
549 | equal | |
550 | .It ne | |
551 | not equal | |
552 | .It gt | |
553 | greater than | |
554 | .It ge | |
555 | greater than or equal to | |
556 | .It lt | |
557 | less than | |
558 | .It le | |
559 | less than or equal to | |
560 | .El | |
561 | .Pp | |
562 | Additionally, the operator may be preceded by one or more of the following modifiers: | |
563 | .Pp | |
564 | .Bl -tag -width "xxx" -compact | |
565 | .It C | |
566 | case-fold | |
567 | .It R | |
568 | regular expression (see | |
569 | .Xr regex 3 ) | |
570 | .It S | |
571 | substring | |
572 | .It A | |
573 | prefix | |
574 | .It Z | |
575 | suffix | |
576 | .It N | |
577 | numeric comparison | |
578 | .El | |
579 | .Pp | |
57b0aad2 A |
580 | More complex search expressions may be built by combining two or more simple expressions. |
581 | A complex expression that has more than one | |
582 | .Dq -k key [[op] val] | |
583 | term matches a message if all of the key-value operations match. | |
b16a592a | 584 | Logically, the result is an AND of all of key-value operations. |
57b0aad2 A |
585 | For example: |
586 | .Pp | |
587 | .Dl syslog -k Sender portmap -k Time ge -2h | |
588 | .Pp | |
589 | finds all messages sent by portmap in the last 2 hours | |
590 | (-2h means "two hours ago"). | |
591 | .Pp | |
b16a592a A |
592 | The |
593 | .Fl o | |
57b0aad2 A |
594 | option may be used to build even more complex searches by providing an OR operation. |
595 | If two or more sub-expressions are given, separated by | |
b16a592a | 596 | .Fl o |
57b0aad2 | 597 | options, then a match occurs is a message matches any of the sub-expressions. |
b16a592a A |
598 | For example, to find all messages which have either a |
599 | .Dq Sender | |
600 | value of | |
601 | .Dq portmap | |
602 | or that have a numeric priority level of 4 or less: | |
603 | .Pp | |
604 | .Dl syslog -k Sender portmap -o -k Level Nle 4 | |
605 | .Pp | |
c4fdb7d1 A |
606 | Log priority levels are internally handled as an integer value between 0 and 7. |
607 | Level values in expressions may either be given as integers, or as string equivalents. | |
608 | See the table string values in the SENDING MESSAGES section for details. | |
609 | The example query above could also be specified with the command: | |
610 | .Pp | |
611 | .Dl syslog -k Sender portmap -o -k Level Nle warning | |
612 | .Pp | |
613 | .Pp | |
b16a592a A |
614 | A special convention exists for matching time stamps. |
615 | An unsigned integer value is regarded as the given number of seconds since | |
616 | 0 hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated Universal Time. | |
617 | An negative integer value is regarded as the given number of seconds before the current time. | |
c4fdb7d1 | 618 | For example, to find all messages of Error priority level (3) or less which were logged in the last 30 seconds: |
b16a592a | 619 | .Pp |
c4fdb7d1 | 620 | .Dl syslog -k Level Nle error -k Time ge -30 |
b16a592a A |
621 | .Pp |
622 | a relative time value may be optionally followed by one of the characters | |
623 | .Dq s , | |
624 | .Dq m , | |
625 | .Dq h , | |
626 | .Dq d , | |
627 | or | |
628 | .Dq w | |
629 | to specify seconds, minutes, hours, days, or weeks respectively. | |
630 | Upper case may be used equivalently. | |
631 | A week is taken to be 7 complete days (i.e. 604800 seconds). | |
b16a592a A |
632 | .Ss FILTERING CONTROLS |
633 | Clients of the Apple System Log facility using either the | |
634 | .Xr asl 3 | |
635 | or | |
636 | .Xr syslog 3 | |
637 | interfaces may specify a log filter mask. | |
638 | The mask specifies which messages should be sent to the | |
639 | .Nm syslogd | |
640 | daemon by specifying a yes/no setting for each priority level. | |
641 | Many clients set a filter mask to avoid sending relatively unimportant messages. | |
642 | Debug or Info priority level messages are generally only useful for debugging operations. | |
643 | By setting a filter mask, a process can improve performance by avoiding spending | |
644 | time sending messages that are in most cases unnecessary. | |
645 | .Pp | |
646 | The | |
647 | .Fl c | |
648 | option may be used to control filtering. | |
649 | In addition to the internal filter value that processes may set as described above, | |
650 | the system maintains a global | |
651 | .Dq master | |
652 | filter. | |
653 | This filter is normally | |
654 | .Dq off , | |
655 | meaning that it has no effect. | |
656 | If a value is set for the master filter, it overrides the local filter for all processes. | |
657 | Root user access is required to set the master filter value. | |
658 | .Pp | |
659 | The current setting of the master filter mask may be inspected using: | |
660 | .Pp | |
661 | .Dl syslog -c 0 | |
662 | .Pp | |
663 | The value of the master filter mask my be set by providing a second argument following | |
664 | .Fl c Ar 0 . | |
665 | The value may a set of characters from the set | |
666 | .Dq pacewnid . | |
667 | These correspond to the priority levels Emergency (Panic), Alert, Critical, Error, Warning, Notice, Info, and Debug. | |
668 | The character | |
669 | .Dq x | |
670 | may be used for Error, as it is used for sending messages. | |
671 | The master filter may be unset with: | |
672 | .Pp | |
673 | .Dl syslog -c 0 off | |
674 | .Pp | |
675 | Since it is common to use the filter as a | |
676 | .Dq cutoff | |
677 | mechanism, for example to cut off messages with Debug and Info priority, | |
678 | a single character from the list above may be specified, preceded by a minus sign. | |
679 | In this case, | |
680 | .Nm | |
681 | uses a filter mask starting at level 0 (Emergency) | |
682 | .Dq up to | |
683 | the given level. | |
684 | For example, to set the master filter level to cause all processes to log messages from Emergency up to Debug: | |
685 | .Pp | |
686 | .Dl syslog -c 0 -d | |
687 | .Pp | |
688 | While the master filter level may be set to control the messages produced by all processes, | |
689 | another filter mask may be specified for an individual process. | |
690 | If a per-process filter mask is set, it overrides both the local filter mask and the master filter mask. | |
691 | The current setting for a per-process filter mask may be inspected using | |
692 | .Fl c Ar process , | |
693 | where | |
694 | .Ar process | |
695 | is either a PID or the name of a process. | |
696 | If a name is used, it must uniquely identify a process. | |
697 | To set a per-process filter mask, an second argument may be supplied following | |
698 | .Fl c Ar process | |
699 | as described above for the master filter mask. | |
700 | Root access is required to set the per-process filter mask for system (UID 0) processes. | |
701 | .Pp | |
db78b1bd | 702 | The |
b16a592a | 703 | .Nm syslogd |
db78b1bd A |
704 | server follows filtering rules specified in the /etc/asl.conf file. |
705 | When the remote-control mechanism is used to change the filter of a process, | |
706 | .Nm syslogd | |
707 | will save any messages received from that process until the remote-control filter is turned off. | |
708 | .Ss SERVER CONFIGURATION | |
709 | When | |
710 | .Nm syslogd | |
711 | starts up, and when it receives a HUP signal, it re-reads its configuration settings from /etc/asl.conf. | |
712 | It is sometimes useful to change configuration parameters temporarily, without needing to make changes | |
713 | to the configuration file. | |
714 | Any of the configuration options that may be set in the file (following an ``='' character) may also | |
715 | be sent to syslogd using the | |
716 | .Fl config | |
717 | flag (without an ``='' character). | |
718 | For example, to temporarily disable the message-per-second limit: | |
b16a592a | 719 | .Pp |
db78b1bd | 720 | .Dl syslog -config mps_limit 0 |
b16a592a | 721 | .Pp |
db78b1bd | 722 | Note that only the superuser (root) may change configuration parameters. |
b16a592a | 723 | .Pp |
db78b1bd A |
724 | In addition to the parameter setting options that are described in the |
725 | .Xr asl.conf 5 | |
726 | manual page, an additional option: | |
b16a592a | 727 | .Pp |
db78b1bd | 728 | .Dl syslog -config reset |
c4fdb7d1 | 729 | .Pp |
db78b1bd | 730 | will cause |
c4fdb7d1 | 731 | .Nm syslogd |
db78b1bd | 732 | to reset its configuration. |
b16a592a A |
733 | .Sh SEE ALSO |
734 | .Xr syslogd 8 , | |
735 | .Xr logger 1 , | |
736 | .Xr asl 3 , | |
737 | .Xr syslog 3 , | |
db78b1bd | 738 | .Xr asl.conf 5 . |
b16a592a A |
739 | .Sh HISTORY |
740 | The | |
741 | .Nm | |
742 | utility appeared in Mac OS X 10.4. |