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