1KRB5_OPENLOG(3)          BSD Library Functions Manual          KRB5_OPENLOG(3)
2

NAME

4     krb5_initlog, krb5_openlog, krb5_closelog, krb5_addlog_dest,
5     krb5_addlog_func, krb5_log, krb5_vlog, krb5_log_msg, krb5_vlog_msg 
6     Heimdal logging functions
7

LIBRARY

9     Kerberos 5 Library (libkrb5, -lkrb5)
10

SYNOPSIS

12     #include <krb5.h>
13
14     typedef void
15     (*krb5_log_log_func_t)(const char *time, const char *message,
16         void *data);
17
18     typedef void
19     (*krb5_log_close_func_t)(void *data);
20
21     krb5_error_code
22     krb5_addlog_dest(krb5_context context, krb5_log_facility *facility,
23         const char *destination);
24
25     krb5_error_code
26     krb5_addlog_func(krb5_context context, krb5_log_facility *facility,
27         int min, int max, krb5_log_log_func_t log,
28         krb5_log_close_func_t close, void *data);
29
30     krb5_error_code
31     krb5_closelog(krb5_context context, krb5_log_facility *facility);
32
33     krb5_error_code
34     krb5_initlog(krb5_context context, const char *program,
35         krb5_log_facility **facility);
36
37     krb5_error_code
38     krb5_log(krb5_context context, krb5_log_facility *facility, int level,
39         const char *format, ...);
40
41     krb5_error_code
42     krb5_log_msg(krb5_context context, krb5_log_facility *facility,
43         char **reply, int level, const char *format, ...);
44
45     krb5_error_code
46     krb5_openlog(krb5_context context, const char *program,
47         krb5_log_facility **facility);
48
49     krb5_error_code
50     krb5_vlog(krb5_context context, krb5_log_facility *facility, int level,
51         const char *format, va_list arglist);
52
53     krb5_error_code
54     krb5_vlog_msg(krb5_context context, krb5_log_facility *facility,
55         char **reply, int level, const char *format, va_list arglist);
56

DESCRIPTION

58     These functions logs messages to one or more destinations.
59
60     The krb5_openlog() function creates a logging facility, that is used to
61     log messages. A facility consists of one or more destinations (which can
62     be files or syslog or some other device). The program parameter should be
63     the generic name of the program that is doing the logging. This name is
64     used to lookup which destinations to use. This information is contained
65     in the logging section of the krb5.conf configuration file.  If no entry
66     is found for program, the entry for default is used, or if that is miss‐
67     ing too, SYSLOG will be used as destination.
68
69     To close a logging facility, use the krb5_closelog() function.
70
71     To log a message to a facility use one of the functions krb5_log(),
72     krb5_log_msg(), krb5_vlog(), or krb5_vlog_msg().  The functions ending in
73     _msg return in reply a pointer to the message that just got logged. This
74     string is allocated, and should be freed with free().  The format is a
75     standard printf() style format string (but see the BUGS section).
76
77     If you want better control of where things gets logged, you can instead
78     of using krb5_openlog() call krb5_initlog(), which just initializes a
79     facility, but doesn't define any actual logging destinations. You can
80     then add destinations with the krb5_addlog_dest() and krb5_addlog_func()
81     functions.  The first of these takes a string specifying a logging desti‐
82     nation, and adds this to the facility. If you want to do some non-stan‐
83     dard logging you can use the krb5_addlog_func() function, which takes a
84     function to use when logging.  The log function is called for each mes‐
85     sage with time being a string specifying the current time, and message
86     the message to log.  close is called when the facility is closed. You can
87     pass application specific data in the data parameter. The min and max
88     parameter are the same as in a destination (defined below). To specify a
89     max of infinity, pass -1.
90
91     krb5_openlog() calls krb5_initlog() and then calls krb5_addlog_dest() for
92     each destination found.
93
94   Destinations
95     The defined destinations (as specified in krb5.conf) follows:
96
97           STDERR
98                This logs to the program's stderr.
99
100           FILE:/file
101
102           FILE=/file
103                Log to the specified file. The form using a colon appends to
104                the file, the form with an equal truncates the file. The trun‐
105                cating form keeps the file open, while the appending form
106                closes it after each log message (which makes it possible to
107                rotate logs). The truncating form is mainly for compatibility
108                with the MIT libkrb5.
109
110           DEVICE=/device
111                This logs to the specified device, at present this is the same
112                as FILE:/device.
113
114           CONSOLE
115                Log to the console, this is the same as DEVICE=/dev/console.
116
117           SYSLOG[:priority[:facility]]
118                Send messages to the syslog system, using priority, and facil‐
119                ity. To get the name for one of these, you take the name of
120                the macro passed to syslog(3), and remove the leading LOG_
121                (LOG_NOTICE becomes NOTICE).  The default values (as well as
122                the values used for unrecognised values), are ERR, and AUTH,
123                respectively.  See syslog(3) for a list of priorities and
124                facilities.
125
126     Each destination may optionally be prepended with a range of logging lev‐
127     els, specified as min-max/.  If the level parameter to krb5_log() is
128     within this range (inclusive) the message gets logged to this destina‐
129     tion, otherwise not. Either of the min and max valued may be omitted, in
130     this case min is assumed to be zero, and max is assumed to be infinity.
131     If you don't include a dash, both min and max gets set to the specified
132     value. If no range is specified, all messages gets logged.
133

EXAMPLES

135           [logging]
136                   kdc = 0/FILE:/var/log/kdc.log
137                   kdc = 1-/SYSLOG:INFO:USER
138                   default = STDERR
139
140     This will log all messages from the kdc program with level 0 to
141     /var/log/kdc.log, other messages will be logged to syslog with priority
142     LOG_INFO, and facility LOG_USER.  All other programs will log all mes‐
143     sages to their stderr.
144

SEE ALSO

146     syslog(3), krb5.conf(5)
147

BUGS

149     These functions use asprintf() to format the message. If your operating
150     system does not have a working asprintf(), a replacement will be used. At
151     present this replacement does not handle some correct conversion specifi‐
152     cations (like floating point numbers). Until this is fixed, the use of
153     these conversions should be avoided.
154
155     If logging is done to the syslog facility, these functions might not be
156     thread-safe, depending on the implementation of openlog(), and syslog().
157
158HEIMDAL                         August 6, 1997                         HEIMDAL
Impressum