]> git.saurik.com Git - apple/syslog.git/blob - syslogd.tproj/asl.conf.5
syslog-267.tar.gz
[apple/syslog.git] / syslogd.tproj / asl.conf.5
1 .\"Copyright (c) 2004-2013 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 Sept 19, 2008
23 .Dt asl.conf 5
24 .Os "Mac OS X"
25 .Sh NAME
26 .Nm asl.conf
27 .Nd configuration file for
28 .Xr syslogd 8
29 and
30 .Xr aslmanager 8
31 .Sh DESCRIPTION
32 The
33 .Xr syslogd 8
34 server reads the /etc/asl.conf file at startup, and re-reads the file when it receives a HUP signal.
35 The
36 .Xr aslmanager 8
37 daemon reads the file when it starts.
38 See the ASLMANAGER PARAMETER SETTINGS section for details on aslmanager-specific parameters.
39 .Pp
40 If the /etc/asl directory exists, then
41 .Nm syslogd
42 and
43 .Nm aslmanager
44 will read each file it contains.
45 These files must have the same format as
46 .Nm asl.conf .
47 Each file configures an independent module, identified by the file name.
48 Modules may be enabled or disabled independently.
49 Each module may specify its own set of rules for acting on received messages.
50 See the ASL MODULES section for details.
51 .Pp
52 The files contain several types of lines, described below.
53 Each type is identified by the first non-whitespace character in the line.
54 .Pp
55 .Bl -tag -width "=" -compact
56 .It =
57 Parameter settings
58 .It ?
59 Query-action rules
60 .It >
61 Output file or directory configuration options
62 .It #
63 Comments
64 .El
65 .Pp
66 Parameter setting lines in the configuration file are generally of the form:
67 .Pp
68 .Dl = parameter_name value ...
69 .Pp
70 Most parameter settings require a single value, although some may take several values.
71 See the PARAMETER SETTINGS section for details.
72 .Pp
73 Query-action rules in the file generally have the form:
74 .Pp
75 .Dl ? query action ...
76 .Pp
77 This directs
78 .Nm syslogd
79 to perform the specified action when a received message matches the given query.
80 Actions may be followed by optional arguments.
81 See the QUERY-ACTION RULES section for details.
82 .Pp
83 Most query-action rules specify output files or ASL-format data stores where matching messages should be saved.
84 The optional parameters for those rules can specify a number of options for these outputs.
85 As a convenience, these configuration options may be specified on a separate line.
86 Output configuration settings in the file begin with a greater-than sign
87 .Dq >
88 followed by a file or ASL directory name and the configuration options for that file or directory.
89 These lines generally have the form:
90 .Pp
91 .Dl > filename option ...
92 .Pp
93 See the OUTPUT CONFIGURATION SETTINGS section for details.
94 .Pp
95 Comment lines are ignored.
96 .Ss PARAMETER SETTINGS
97 The following parameter-settings are recognized by
98 .Nm syslogd .
99 .Pp
100 .Bl -tag -width "bsd_max_dup_time" -compact -offset indent
101 .It debug
102 Enables or disables internal debugging output.
103 This is probably of little interest to most users.
104 The debug parameter requires a value of
105 .Dq 1
106 to enable debug output, or a value of
107 .Dq 0
108 to disable it.
109 Debugging messages are written to /var/log/syslogd.log.
110 .Pp
111 .It mark_time
112 Sets the time interval for the mark facility.
113 The default is 0 seconds, which indicates that mark messages are not generated.
114 .Pp
115 .It dup_delay
116 Sets the maximum time before writing a
117 .Dq "last message repeated <N> times"
118 message in a log file when duplicate messages have been detected.
119 The default is 30 seconds.
120 .Pp
121 .It utmp_ttl
122 Sets the time-to-live for messages used by the utmp, wtmp, and lastlog subsystems.
123 The default is 31622400 seconds (approximately 1 year).
124 .Pp
125 .It mps_limit
126 Sets the kernel message per second quota.
127 The default is value is 500.
128 A value of 0 disables the quota mechanism.
129 Note that this setting only limits the number of kernel messages that will be saved by
130 .Nm syslogd .
131 User processes are limited to 36000 messages per hour.
132 The limit for a user process is not enforced if a remote-control ASL filter is in
133 place for the process.
134 See the
135 .Xr syslog 1
136 manual for enabling a remote-control filter using the
137 .Fl c
138 option with the
139 .Nm syslog
140 command.
141 .Pp
142 .It max_file_size
143 Sets the maximum file size for individual files in the ASL database.
144 The default is 25600000 bytes.
145 .El
146 .Ss QUERY-ACTION RULES
147 Query-action rules are used to cause
148 .Nm syslogd
149 to perform specific actions when received messages match a specified query pattern.
150 For example, to save certain messages in a file.
151 The rules are processed in the order in which they appear in the file.
152 This matters because some actions can affect further processing.
153 For example, an
154 .Dq ignore
155 action causes
156 .Nm syslogd
157 to stop processing the rules in a file for messages that match a given query pattern.
158 .Pp
159 Query-action rules contain three components: a query, an action, and optional parameters specific to that action.
160 For example, the following rule matches log messages sent by the
161 .Dq example
162 process which have log priority levels in the range emergency to error.
163 If a received message matches,
164 .Nm syslogd
165 posts a BSD notification for the key
166 .Dq com.example.log_message .
167 .Pp
168 .Dl ? [= Sender example] [<= Level error] notify com.example.log_message
169 .Ss Query Format
170 Queries comprise one or more message matching components, each of which has the form:
171 .Pp
172 .Dl [OP KEY VAL]
173 .Pp
174 OP is a comparison operator.
175 It can have the following values:
176 .Pp
177 .Bl -tag -width "<= " -compact -offset indent
178 .It T
179 true (always matches)
180 .It =
181 equal
182 .It !
183 not equal
184 .It >
185 greater than
186 .It >=
187 greater than or equal to
188 .It <
189 less than
190 .It <=
191 less than or equal to
192 .El
193 .Pp
194 It can also be preceded by one or more modifiers:
195 .Bl -tag -width "C " -compact -offset indent
196 .Pp
197 .It C
198 casefold
199 .It N
200 numeric comparison
201 .It S
202 substring
203 .It A
204 prefix
205 .It Z
206 suffix
207 .El
208 .Pp
209 KEY and VAL are message keys and values.
210 For example
211 .Pp
212 .Dl [= Sender example]
213 .Pp
214 matches any message with value
215 .Dq example
216 for the
217 .Dq Sender
218 key.
219 The query
220 .Pp
221 .Dl [CA= Color gr]
222 .Pp
223 matches any message with a value beginning with the letters GR, Gr, gr, or gR
224 (
225 .Dq C
226 meaning casefold,
227 .Dq A
228 meaning prefix) for the
229 .Dq Color
230 key.
231 The example query above,
232 .Pp
233 .Dl [= Sender example] [N< Level 3]
234 .Pp
235 matches any message from
236 .Dq example
237 with a level numerically less than 3
238 (string values are converted to integers, and the comparison is done on the integer values).
239 Note that the string values may be used equivalently for the Level key,
240 so the example above may also be written as:
241 .Pp
242 .Dl [= Sender example] [< Level Error]
243 .Pp
244 String values for levels may be any of the set
245 .Dq emergency ,
246 .Dq alert ,
247 .Dq critical ,
248 .Dq error ,
249 .Dq warning ,
250 .Dq notice ,
251 .Dq info ,
252 or
253 .Dq debug .
254 These strings may be upper, lower, or mixed case.
255 .Pp
256 The
257 .Dq T
258 operator is useful to test for the presence of a particular key.
259 .Pp
260 .Dl [T Flavor]
261 .Pp
262 Will match any message that has a
263 .Dq Flavor
264 key, regardless of its value.
265 .Pp
266 Note that space characters and closing square bracket characters (']') are specially processed.
267 The first space character following the beginning of a key delimits the key.
268 The first closing square bracket following the beginning of a value delimits the value.
269 So '[= foo bar\ ]'
270 will match messages which have a key 'foo' with the value 'bar ', including a trailing space character.
271 .Pp
272 As a special case, the query
273 .Pp
274 .Dl *
275 .Pp
276 matches all messages.
277 .Ss Actions
278 The following actions are available.
279 .Pp
280 .Bl -tag -width "directory" -compact -offset indent
281 .It store
282 Causes
283 .Nm syslogd
284 to save matching messages in the ASL database.
285 Note that if /etc/asl.conf contains no
286 .Dq store
287 action rules, then
288 .Nm syslogd
289 will save all messages it receives in the ASL database.
290 .Pp
291 .It file
292 Causes matching messages to be stored in a log file.
293 The file's path name must follow as the first parameter.
294 If the path already exists, it must be a plain file.
295 If the file does not exist, it will be created when the first message is written.
296 If the pathname specified is not an absolute path,
297 .Nm syslogd
298 will treat the given path as relative to /var/log (for /etc/asl.conf),
299 or for other output modules relative to /var/log/module/NAME where NAME is the module name.
300 .Pp
301 By default, the file's owner will be root, and the file will be readable by the admin group.
302 Various options may follow the file name to specify ownership and access controls,
303 printed log message format, and controls for file rotation, compression, time-to-live,
304 and other aspects of output file life-cycle management.
305 See the OUTPUT CONFIGURATION SETTINGS section for more details.
306 .Pp
307 .It directory
308 Causes matching messages to be stored in an ASL-format log message data store.
309 A directory path name must follow as the first parameter.
310 If the path exists, it must be a directory.
311 .Pp
312 Messages saved to an ASL directory are saved in files that are named
313 .Dq yyyy.mm.dd.asl ,
314 where
315 .Dq yyyy ,
316 .Dq mm ,
317 and
318 .Dq dd
319 are the year, month (01 to 12) and day of the month (01 to 31) associated with
320 matching messages.
321 This has the effect of saving messages in a separate file for each day.
322 .Pp
323 By default, files in the directory will be owned by root, and readable by the admin group.
324 Various options may follow the directory name to control ownership, access controls,
325 and the management of the store and its contents.
326 See the OUTPUT CONFIGURATION SETTINGS section for a list of options that may be set for store directories.
327 .Pp
328 .It notify
329 Causes
330 .Nm syslogd
331 to post a notification with
332 .Fn notify_post .
333 The notification key must appear as a single parameter following the
334 .Dq notify
335 action.
336 .Pp
337 .It skip
338 Causes a matching message to be ignored in all subsequent matching rules in the file.
339 Its scope is local to a single module configuration file.
340 .Pp
341 .It claim
342 Messages that match the query associated with a
343 .Dq claim
344 action are not processed by the main ASL configuration file /etc/asl.conf.
345 While claimed messages are not processed by /etc/asl.conf,
346 they are not completely private.
347 Other modules may also claim messages,
348 and in some cases two or more modules may have claim actions
349 that match the same messages.
350 This action only blocks processing by /etc/asl.conf.
351 .Pp
352 The
353 .Dq claim
354 action may be followed by the keyword
355 .Dq only .
356 In this case, only those messages that match the
357 .Dq claim only
358 query will be processed by subsequent rules in the module.
359 .Pp
360 .It access
361 Sets read access controls for messages that match the associated query pattern.
362 .Nm syslogd
363 will restrict read access to matching messages to a specific user and group.
364 The user ID number and group ID number must follow the
365 .Dq access
366 keyword as parameters.
367 .Pp
368 .It broadcast
369 Causes syslogd to write the text of matching messages to all terminal windows.
370 If optional text follows the
371 .Dq broadcast
372 keyword, then that text is written rather that the matching message text.
373 Note that this action is restricted to the main ASL configuration file /etc/asl.conf.
374 .Pp
375 .It ignore
376 Causes a matching message to be ignored in all subsequent matching rules in the file.
377 This action is equivalent to the
378 .Dq skip
379 action in all module configuration files except the main ASL configuration file /etc/asl.conf.
380 When used in the main configuration file, the scope of the action is global,
381 and matching messages will be ignored by all ASL modules.
382 .El
383 .Ss OUTPUT CONFIGURATION SETTINGS
384 Various options may follow the path name in a
385 .Dq file
386 or
387 .Dq directory
388 query-action rule.
389 For example, the following rule specifies that all messages from the
390 .Dq example
391 facility will be saved in the file
392 .Dq example.log ,
393 and that messages are printed in a
394 .Dq raw
395 format that shows all the keys and values in the message:
396 .Pp
397 .Dl ? [= Facility example] file example.log format=raw
398 .Pp
399 Multiple options may be specified separated by whitespace characters.
400 For example:
401 .Pp
402 .Dl ? [= Facility example] file example.log format=raw rotate=local compress ttl=3 mode=0640 uid=0 gid=5 gid=20
403 .Pp
404 As a convenience, a file or directory name and any associated options can be specified on a separate
405 output configuration line following a
406 .Dq >
407 character:
408 .Pp
409 .Dl > example.log format=raw rotate=local compress ttl=3 mode=0640 uid=0 gid=5 gid=20
410 .Pp
411 Options for a file or directory are taken from the first query-action rule
412 or output configuration line for the given path.
413 A good usage pattern for multiple rules that specify the same output file or directory is:
414 .Pp
415 .Dl > example.log options ...
416 .Dl ? query1 file example.log
417 .Dl ? query2 file example.log
418 .Dl ? query3 file example.log
419 .Pp
420 Most of the options listed below may be used with either file or directory outputs.
421 Exceptions are noted.
422 .Pp
423 .Bl -tag -width "coalesce=VAL" -compact -offset indent
424 .It format=FMT
425 Controls the format of log messages saved in a file.
426 Note that this option is specific to file outputs.
427 It is ignored for ASL directories.
428 .Pp
429 The format is specified by the value given for FMT.
430 Several pre-defined formats are available:
431 .Bl -tag -width "abcd"
432 .It bsd
433 Format used by the
434 .Nm syslogd
435 daemon for system log files, e.g. /var/log/system.log.
436 .It std
437 Standard (default) format.
438 Similar to
439 .Dq bsd ,
440 but includes the message priority level.
441 .It raw
442 Prints the complete message structure.
443 Each key/value pair is enclosed in square brackets.
444 Embedded closing brackets and white space are escaped.
445 Time stamps are printed as seconds since the epoch.
446 .It xml
447 The list of messages is printed as an XML property list.
448 Each message is represented as a dictionary in a array.
449 Dictionary keys represent message keys.
450 Dictionary values are strings.
451 .It asl
452 The output file is written as an ASL-format data store file.
453 Files in this format may be read and searched using the
454 .Nm syslog
455 command line utility with the use of the
456 .Fl f Ar path
457 option.
458 .El
459 .Pp
460 Custom format strings may also be specified.
461 Since custom formats often contain white-space characters,
462 the entire string may be enclosed in single or double quote characters,
463 or each white-space character may be preceded by a backslash escape character.
464 Escaped characters are not interpreted.
465 Custom format strings are described in detail in the READING MESSAGES section of the
466 .Xr syslog 1
467 manual.
468 .Pp
469 .It mode=MMM
470 Sets the mode of the file or files within an ASL directory.
471 The value MMM may be specified as a decimal value,
472 a hexadecimal value (if preceded by ``0x''),
473 or octal value (if preceded by ``0'').
474 .Pp
475 .It uid=UUU
476 Specifies the file's owner.
477 If more than one
478 .Dq uid=UUU
479 option is given, the first will be used to set ownership,
480 and subsequent user IDs will be given read access to in the files POSIX.1e ACLs.
481 Note that UIDs should be defined in the local Open Directory database, since
482 .Nm syslogd
483 starts and may create the log file before network directory services are available.
484 Unknown UIDs and GIDs will be ignored when setting access controls.
485 .Pp
486 .It gid=GGG
487 Specifies the file's group.
488 If more than one
489 .Dq gid=GGG
490 option is given, the first will be used to set the file's group,
491 and subsequent group IDs will be given read access to in the files POSIX.1e ACLs.
492 As with UID=UUU options, groups should be defined in the local Open Directory database.
493 .Pp
494 .It coalesce=VAL
495 By default, files printed using the
496 .Dq bsd
497 and
498 .Dq std
499 formats will coalesce duplicates.
500 If two or more messages are logged within 30 seconds, and which differ only in time,
501 then the second and subsequent messages will not be printed.
502 When a different message is logged, or 30 seconds have elapsed since the initial
503 message was logged, a line with the text
504 .Dl --- last message repeated N times ---
505 will be added to the file.
506 The default is
507 .Dq coalesce=1 .
508 The default may be overridden by specifying
509 .Dq coalesce=0 .
510 The values
511 .Dq off
512 and
513 .Dq false
514 may be used in place of
515 .Dq 0 .
516 .El
517 .Pp
518 The following options all deal with file rotation and life-cycle management.
519 The FILE ROTATION section describes this in detail.
520 .Pp
521 .Bl -tag -width "rotate=NAME_STYLE" -compact -offset indent
522 .Pp
523 .It rotate=NAME_STYLE
524 Enables log file rotation and specifies the file naming scheme for rotated files.
525 This option does not apply to ASL directories.
526 Four styles are supported:
527 .Pp
528 .Bl -tag -width "local-basic" -compact -indent
529 .It sec
530 Rotated file names are of the form
531 .Dq example.log.T1340607600 .
532 The file names include the creation time of the file in seconds since the epoch.
533 .Pp
534 .It utc
535 Rotated file names are in ISO 8601 extended format, for example
536 .Dq example.log.2012-06-24T07:00:00Z .
537 The file names includes its creation time as a UTC date and time.
538 .Pp
539 .It utc-basic
540 Rotated file names are in ISO 8601 basic format, for example
541 .Dq example.log.20120624T070000Z .
542 The file names includes its creation time as a UTC date and time.
543 .Pp
544 .It local
545 Rotated file names are in ISO 8601 extended format, for example
546 .Dq example.log.2012-06-24T07:00:00-7 .
547 The file names includes its creation time as date and time in the local time zone.
548 The local timezone offset is included as a trailing part of the name.
549 .Pp
550 .It local-basic
551 Rotated file names are in ISO 8601 basic format, for example
552 .Dq example.log.20120624T070000-07 .
553 The file names includes its creation time as date and time in the local time zone.
554 The local timezone offset is included as a trailing part of the name.
555 .Pp
556 .It seq
557 Rotated file names are of the form
558 .Dq example.log.N
559 where N is an integer sequence number.
560 Files are re-numbered on each rotation so that the
561 .Dq 0
562 file is the most recent.
563 .El
564 .Pp
565 If the option
566 .Dq rotate
567 appears without a value, the naming style defaults to
568 .Dq "sec" .
569 .Pp
570 Note that using the local timezone for timestamped files may cause odd behavior on highly-mobile systems.
571 .Nm aslmanager
572 will delete files after a specified time-to-live (see below).
573 The age of the file is determined by the file name.
574 If files are created in different timezones but saved with a non-absolute timestamp,
575 the age calculation may result in some files being considered older or newer than they are in reality.
576 .Pp
577 Also note that sequenced files (using the
578 .Dq seq
579 style) will initially be checkpointed using a file name containing a timestamp in seconds.
580 .Nm aslmanager
581 will re-sequence the files when it scans for checkpoint files.
582 .Pp
583 .It ttl=DAYS
584 Specifies the number of days that older versions of rotated files should be allowed to remain in the filesystem.
585 Rotated files older than this limit are deleted.
586 .Pp
587 .It dest=PATH
588 By default, rotated files are left in the same directory as the original file.
589 However, in some cases it may be useful to move the rotated versions to a different
590 directory for archival or other reasons.
591 If this option is specified,
592 .Nm aslmanager
593 will move files to the directory given by PATH.
594 .Pp
595 .It soft
596 Makes
597 .Nm syslogd
598 ignore write errors when saving messages.
599 Normally,
600 .Nm syslogd
601 will stop saving to a file or ASL directory after 5 consecutive write errors.
602 .Pp
603 .It compress
604 Enables gzip file compression for rotated log files.
605 When compressed, the extension
606 .Dq .gz
607 is appended to the file name.
608 .Pp
609 .It file_max=SIZE
610 Limits the size of an active log file.
611 SIZE may be an integer number of bytes, or the value may be followed by a single character
612 .Dq k ,
613 .Dq m ,
614 or
615 .Dq g
616 (upper or lower case),
617 to indicate a size limit in multiples of 1024 (kibibyte), 1048576 (mebibyte), or 1073741824 (gibibyte).
618 If a file exceeds this limit, it is immediately checkpointed by
619 .Nm syslogd
620 and a new file is opened.
621 Note that
622 .Dq file_max
623 specifies a size limit before file compression is performed if the
624 .Dq compress
625 option is also present.
626 .Pp
627 .It all_max=SIZE
628 Specifies a size limit for the total of all rotated versions of a file.
629 .Nm aslmanager
630 will delete rotated files, oldest first, to reduce the total below the limit.
631 SIZE may be specified in the same format as the file_max option.
632 .El
633 .Ss FILE ROTATION
634 .Nm syslogd
635 and
636 .Nm aslmanager
637 work together to automatically provide all the features of file rotation.
638 However, it is useful to understand how the process works.
639 This section describes the file rotation options that may be used in /etc/asl.conf
640 or an ASL Output Module configuration file,
641 together with a description of how the system works to support those features.
642 .Pp
643 If a file is marked for rotation,
644 .Nm syslogd
645 will close the file at the start of a new day or when the file exceeds its
646 .Dq file_max
647 size limit.
648 At that point,
649 .Nm syslogd
650 renames the file and starts a new file to continue logging.
651 The old file is renamed with the file's creation time included in its name.
652 This operation is called checkpointing the file.
653 .Pp
654 For example,
655 .Nm syslogd
656 might close
657 .Dq example.log
658 and rename it
659 .Dq example.log.T1340521200 ,
660 1340521200 being the time that the file was created.
661 It would then start a new
662 .Dq example.log
663 file and use it until midnight, when the cycle would be repeated.
664 .Pp
665 Files are normally checkpointed at midnight.
666 If the system is sleeping or powered off, then files are checkpointed when
667 the the first message of a new day (local time) is received.
668 Files are also checkpointed if they exceed a size limit specified by a file_max option,
669 and they may be checkpointed manually through options provided by the
670 .Xr syslog 1
671 and
672 .Xr aslmanager 8
673 utilities.
674 The checkpointed file name always contains the file's creation time.
675 If the options for the file include
676 .Dq rotate=utc
677 then the timestamp will be a UTC date and time string.
678 .Dq rotate=local
679 causes the timestamp to be the date and time in the current local timezone.
680 Otherwise, the timestamp will be in seconds since the epoch.
681 .Pp
682 .Nm syslogd
683 only performs the checkpointing operation.
684 It closes old files, moves them out of the way, and starts writing new files.
685 Most of the work of file rotation is done by the
686 .Xr aslmanager 8
687 utility.
688 That includes moving files to a destination directory, compressing files,
689 re-naming files according to one of the naming style options,
690 deleting old files after they exceed their time-to-live,
691 and checking file space usage.
692 .Pp
693 .Nm aslmanager
694 normally runs once during system start-up, and once a day just after midnight.
695 It may also be triggered occasionally by
696 .Nm syslogd ,
697 and it may be run manually.
698 .Pp
699 .Nm aslmanager
700 scans for any checkpointed files created by
701 .Nm syslogd
702 and will rename the files (if required) to match the naming style specified by the
703 .Dq rotate=NAME_STYLE
704 option.
705 If
706 .Dq rotate=seq
707 is specified for a file, checkpointed files created by
708 .Nm syslogd
709 contain a timestamp in seconds.
710 These files are renamed so that the file names
711 contain a sequence number.
712 The most recent version has the number
713 .Dq 0 ,
714 and older versions have higher numbers.
715 For example:
716 .Pp
717 .Dl example.log.0
718 .Dl example.log.1
719 .Dl example.log.2
720 .Dl ...
721 .Pp
722 As well as renaming files,
723 .Nm aslmanager
724 may perform other actions.
725 If the file has been given a
726 .Dq dest=PATH
727 option,
728 the rotated versions of the file will be moved to the specified directory.
729 Files will be gzip compressed using the
730 .Xr zlib 3
731 library if the
732 .Dq compress
733 option has been given.
734 If the total size of all the rotated versions of the file exceeds a value given in an
735 .Dq all_max
736 option, older versions of the rotated file will be deleted to keep the total below the specified limit.
737 .Pp
738 Although checkpoint and file rotation operations are normally done automatically,
739 .Nm aslmanager
740 supports an option that will trigger
741 .Nm syslogd
742 to checkpoint files before
743 .Nm aslmanager
744 starts its scan.
745 .Nm syslog
746 also supports an option to force files to be checkpointed without running
747 .Nm aslmanager .
748 See the
749 .Xr aslmanager 8
750 and
751 .Xr syslog 1
752 manuals for details.
753 .Pp
754 Programmatically, an
755 .Xr asl 3
756 message may be sent to syslogd to force it to checkpoint either a single file,
757 or to checkpoint all files for a particular ASL module.
758 To checkpoint all files:
759 .Pp
760 const char *module_name;
761 .Pp
762 //TODO: set module_name
763 asl_object_t ctl = asl_new(ASL_TYPE_MSG);
764 asl_set(ctl, ASL_KEY_OPTION, "control");
765 asl_log(NULL, ctl, ASL_LEVEL_NOTICE, "@ %s checkpoint", module_name);
766 asl_release(ctl);
767 .Pp
768 To checkpoint just one file:
769 .Pp
770 const char *module_name;
771 const char *file_name;
772 .Pp
773 //TODO: set module_name
774 //TODO: set file_name
775 asl_object_t ctl = asl_new(ASL_TYPE_MSG);
776 asl_set(ctl, ASL_KEY_OPTION, "control");
777 asl_log(NULL, ctl, ASL_LEVEL_NOTICE, "@ %s checkpoint %s", module_name, file_name);
778 asl_release(ctl);
779 .Pp
780 .Ss ASL OUTPUT MODULES
781 .Pp
782 An ASL output module is created by a configuration file in the directory /etc/asl.
783 The file name is used as the module's name.
784 The format of the file is generally the same as
785 .Nm asl.conf
786 with a few exceptions.
787 Modules may not have parameter setting lines for the system parameters listed in the
788 PARAMETER SETTINGS or ASLMANAGER PARAMETER SETTINGS sections,
789 nor may they include
790 .Dq broadcast
791 query-action rules.
792 .Pp
793 Module configuration files are read by
794 .Nm syslogd
795 when it starts, and whenever it gets a HUP signal.
796 Messages received by
797 .Nm syslogd
798 are first processed according the the rules found in /etc/asl.conf
799 (also known as the
800 .Dq com.apple.asl
801 module), then the message is processed by the
802 rules from each module found in /etc/asl.
803 .Pp
804 An exception to this is that messages that match the query in a
805 .Dq claim
806 action rule in any module are not processed by the rules in /etc/asl.conf.
807 .Pp
808 ASL output modules are enabled by default, but a module may include a parameter setting:
809 .Pp
810 .Dl = enable 0
811 .Pp
812 The module is still loaded by
813 .Nm syslogd ,
814 but the module will not save messages to files or directories, and will not post BSD notifications.
815 .Pp
816 Several mechanisms allow modules to be enabled or disabled dynamically.
817 One mechanism allows the setting of the
818 .Dq enable
819 parameter to be based on the existence of a path in the filesystem,
820 or on the value associated with a dictionary key in a property list file.
821 On iOS only, the value of a key in an installed configuration profile may be tested.
822 .Pp
823 To enable a module based on the existence of a file, the module may use:
824 .Pp
825 .Dl = enable [File /a/b/c]
826 .Pp
827 where
828 .Dq /a/b/c
829 may be any filesystem path.
830 .Pp
831 To enable a module based on the value of a dictionary key in a property list file,
832 .Pp
833 .Dl = enable [Plist /path/config.plist] [= SomeKey SomeValue]
834 .Pp
835 Any of the test operations described above in the QUERY-ACTION RULES section
836 may also be used in testing key / value pairs.
837 Multiple operations are also allowed, for example:
838 .Pp
839 .Dl = enable [Plist /path/config.plist] [N>= DebugLevel 7] [S= Othervalue xyz]
840 .Pp
841 If the property list file does not exist, the test will evaluate to zero.
842 The file may be in binary or xml format.
843 It may only contain a single dictionary object at its top level.
844 Only keys and values at the top level of the dictionary may be tested.
845 Values must be strings, integer values, doubles, UUIDs, dates, or booleans.
846 Boolean <true/> and <false/> values are converted to 1 and 0 respectively.
847 Values are converted into strings,
848 and string comparisons are used unless unless an
849 .Dq N
850 modifier is specified with the test operator.
851 .Pp
852 On iOS, a module may test key / value pairs in a configuration profile using the
853 same key / value tests that may be used for property list files.
854 .Pp
855 .Dl = enable [Profile name] [= Verbose 1]
856 .Pp
857 The profile name is the value of its DefaultsDomainName key.
858 The test will evaluate to zero if the profile is not installed.
859 .Pp
860 A module may be also enabled or disabled using
861 .Nm syslog
862 or by sending
863 .Nm syslogd
864 a special
865 .Xr asl 3
866 control message.
867 Only the user
868 .Dq root
869 may enable or disable modules.
870 .Pp
871 A module may be enabled or disabled by sending an
872 .Xr asl 3
873 message as shown in this example:
874 .Pp
875 int enable;
876 const char *module_name;
877 .Pp
878 //TODO: set module_name
879 //TODO: set enable to 0 or 1
880 asl_object_t ctl = asl_new(ASL_TYPE_MSG);
881 asl_set(ctl, ASL_KEY_OPTION, "control");
882 asl_log(NULL, ctl, ASL_LEVEL_NOTICE, "@ %s enable %d", module_name, enable);
883 asl_release(ctl);
884 .Pp
885 A control message may also be sent using
886 .Nm syslog
887 as the following example shows to disable a module named
888 .Dq com.apple.example :
889 .Pp
890 .Dl sudo syslog -module com.apple.example enable 0
891 .Pp
892 A module may also enable or disable itself.
893 Although a module that is not enabled will not write or post notifications,
894 it still will scan messages.
895 The module may contain conditional parameter-setting rules like:
896 .Pp
897 .Dl = [= Color Green] enable 1
898 .Dl = [= Color Red] enable 0
899 .Pp
900 This is similar to a query-action rule.
901 If a message received by syslogd matches the specified query,
902 in this case having a Color key with the value Green or Red,
903 then the enable parameter is set as specified.
904 So in this example, the module would be enabled and disabled
905 whenever syslogd received a message containing the appropriate value for the
906 .Dq Color
907 key.
908 .Ss ASLMANAGER PARAMETER SETTINGS
909 The following parameter-settings are recognized by
910 .Nm aslmanager .
911 .Pp
912 .Bl -tag -width "aslmanager_debug" -compact -offset indent
913 .It aslmanager_debug
914 Enables or disables internal debugging output.
915 This is probably of little interest to most users.
916 The debug parameter requires a value of
917 .Dq 1
918 to enable debug output, or a value of
919 .Dq 0
920 to disable it.
921 Debug messages are saved in an auxiliary file attached to an ASL log message.
922 The file may be inspected by opening the file attachement from the Console utility.
923 .Pp
924 .It store_ttl
925 Sets the time-to-live in days for messages in the ASL database.
926 The default is 7 days.
927 .Pp
928 .It max_store_size
929 Sets the maximum size for for the ASL database.
930 The default is 150000000 bytes.
931 .Pp
932 .It archive
933 Enables or disables archiving of the ASL database.
934 The archive parameter requires a value of
935 .Dq 1
936 to enable archiving, or a value of
937 .Dq 0
938 to disable it.
939 An optional archive directory path may follow the
940 .Dq 0
941 or
942 .Dq 1 .
943 If enabled, files removed from the ASL database are moved to the archive directory.
944 The default archive directory path is /var/log/asl.archive.
945 .Pp
946 .It store_path
947 The ASL database path used by
948 .Nm aslmanager .
949 The default is /var/log/asl.
950 Note that this parameter is ignored by
951 .Nm syslogd .
952 .Pp
953 .It archive_mode
954 Files copied to the ASL database archive will be given the specified access mode.
955 The default is 0400, so archive files will only be readable by root.
956 .El
957 .Pp
958 .Sh SEE ALSO
959 .Xr asl 3 ,
960 .Xr notify 3 ,
961 .Xr syslog 1 ,
962 .Xr aslmanager 8 ,
963 .Xr syslogd 8 .