1logger_disk_log_h(3)       Erlang Module Definition       logger_disk_log_h(3)
2
3
4

NAME

6       logger_disk_log_h - A disk_log based handler for Logger
7

DESCRIPTION

9       This is a handler for Logger that offers circular (wrapped) logs by us‐
10       ing disk_log. Multiple instances of this handler can be added  to  Log‐
11       ger,  and  each  instance prints to its own disk log file, created with
12       the name and settings specified in the handler configuration.
13
14       The default standard  handler,  logger_std_h,  can  be  replaced  by  a
15       disk_log  handler  at startup of the Kernel application. See an example
16       of this below.
17
18       The handler has an overload protection mechanism that keeps the handler
19       process  and  the  Kernel  application  alive  during high loads of log
20       events. How overload protection works, and how to configure it, is  de‐
21       scribed in the User's Guide.
22
23       To  add  a  new  instance  of the disk_log handler, use logger:add_han‐
24       dler/3. The handler configuration argument is a map which  can  contain
25       general  configuration  parameters,  as documented in the User's Guide,
26       and handler specific parameters. The specific data is stored in  a  sub
27       map with the key config, and can contain the following parameters:
28
29         file:
30           This  is the full name of the disk log file. The option corresponds
31           to the name property in the dlog_option() datatype.
32
33           The value is set when the  handler  is  added,  and  it  cannot  be
34           changed in runtime.
35
36           Defaults  to  the same name as the handler identity, in the current
37           directory.
38
39         type:
40           This is the disk log type, wrap or halt. The option corresponds  to
41           the type property in the dlog_option() datatype.
42
43           The  value  is  set  when  the  handler  is added, and it cannot be
44           changed in runtime.
45
46           Defaults to wrap.
47
48         max_no_files:
49           This is the maximum number of files that disk_log uses for its cir‐
50           cular  logging. The option corresponds to the MaxNoFiles element in
51           the size property in the dlog_option() datatype.
52
53           The value is set when the  handler  is  added,  and  it  cannot  be
54           changed in runtime.
55
56           Defaults to 10.
57
58           The setting has no effect on a halt log.
59
60         max_no_bytes:
61           This  is  the maximum number of bytes that is written to a log file
62           before disk_log proceeds with the next file in order, or  generates
63           an  error in case of a full halt log. The option corresponds to the
64           MaxNoBytes element  in  the  size  property  in  the  dlog_option()
65           datatype.
66
67           The  value  is  set  when  the  handler  is added, and it cannot be
68           changed in runtime.
69
70           Defaults to 1048576 bytes for a wrap log, and infinity for  a  halt
71           log.
72
73         filesync_repeat_interval:
74           This value, in milliseconds, specifies how often the handler does a
75           disk_log sync operation to write buffered data to disk. The handler
76           attempts  the operation repeatedly, but only performs a new sync if
77           something has actually been logged.
78
79           Defaults to 5000 milliseconds.
80
81           If no_repeat is set as value, the repeated sync operation  is  dis‐
82           abled.  The user can also call the filesync/1 function to perform a
83           disk_log sync.
84
85       Other configuration parameters exist, to be used  for  customizing  the
86       overload protection behaviour. The same parameters are used both in the
87       standard handler and the disk_log handler, and are  documented  in  the
88       User's Guide.
89
90       Notice  that when changing the configuration of the handler in runtime,
91       the disk_log options (file, type, max_no_files, max_no_bytes) must  not
92       be modified.
93
94       Example of adding a disk_log handler:
95
96       logger:add_handler(my_disk_log_h, logger_disk_log_h,
97                          #{config => #{file => "./my_disk_log",
98                                        type => wrap,
99                                        max_no_files => 4,
100                                        max_no_bytes => 10000,
101                                        filesync_repeat_interval => 1000}}).
102
103
104       To  use  the  disk_log  handler instead of the default standard handler
105       when starting an Erlang node, change the Kernel default logger  to  use
106       logger_disk_log_h. Example:
107
108       erl -kernel logger '[{handler,default,logger_disk_log_h,
109                             #{config => #{file => "./system_disk_log"}}}]'
110
111

EXPORTS

113       filesync(Name) -> ok | {error, Reason}
114
115              Types:
116
117                 Name = atom()
118                 Reason = handler_busy | {badarg, term()}
119
120              Write buffered data to disk.
121

SEE ALSO

123       logger(3), logger_std_h(3), disk_log(3)
124
125
126
127Ericsson AB                     kernel 7.3.1.1            logger_disk_log_h(3)
Impressum