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