1 *java.util.logging.FileHandler* *FileHandler* Simple file logging Handler.
3 public class FileHandler
4 extends |java.util.logging.StreamHandler|
6 |java.util.logging.FileHandler_Description|
7 |java.util.logging.FileHandler_Fields|
8 |java.util.logging.FileHandler_Constructors|
9 |java.util.logging.FileHandler_Methods|
11 ================================================================================
13 *java.util.logging.FileHandler_Constructors*
14 |java.util.logging.FileHandler()|Construct a default FileHandler.
15 |java.util.logging.FileHandler(String)|Initialize a FileHandler to write to the
16 |java.util.logging.FileHandler(String,boolean)|Initialize a FileHandler to writ
17 |java.util.logging.FileHandler(String,int,int)|Initialize a FileHandler to writ
18 |java.util.logging.FileHandler(String,int,int,boolean)|Initialize a FileHandler
20 *java.util.logging.FileHandler_Methods*
21 |java.util.logging.FileHandler.close()|Close all the files.
22 |java.util.logging.FileHandler.publish(LogRecord)|Format and publish a LogRecor
24 *java.util.logging.FileHandler_Description*
26 Simple file logging Handler.
28 The FileHandler can either write to a specified file, or it can write to a
29 rotating set of files.
31 For a rotating set of files, as each file reaches a given size limit, it is
32 closed, rotated out, and a new file opened. Successively older files are named
33 by adding "0", "1", "2", etc into the base filename.
35 By default buffering is enabled in the IO libraries but each log record is
36 flushed out when it is complete.
38 By default the XMLFormatter class is used for formatting.
40 Configuration: By default each FileHandler is initialized using the following
41 LogManager configuration properties. If properties are not defined (or have
42 invalid values) then the specified default values are used.
44 java.util.logging.FileHandler.level specifies the default level for the Handler
45 (defaults to Level.ALL). java.util.logging.FileHandler.filter specifies the
46 name of a Filter class to use (defaults to no Filter).
47 java.util.logging.FileHandler.formatter specifies the name of a Formatter class
48 to use (defaults to java.util.logging.XMLFormatter)
49 java.util.logging.FileHandler.encoding the name of the character set encoding
50 to use (defaults to the default platform encoding).
51 java.util.logging.FileHandler.limit specifies an approximate maximum amount to
52 write (in bytes) to any one file. If this is zero, then there is no limit.
53 (Defaults to no limit). java.util.logging.FileHandler.count specifies how many
54 output files to cycle through (defaults to 1).
55 java.util.logging.FileHandler.pattern specifies a pattern for generating the
56 output file name. See below for details. (Defaults to "%h/java%u.log").
57 java.util.logging.FileHandler.append specifies whether the FileHandler should
58 append onto any existing files (defaults to false).
62 A pattern consists of a string that includes the following special components
63 that will be replaced at runtime:
65 "/" the local pathname separator "%t" the system temporary directory "%h" the
66 value of the "user.home" system property "%g" the generation number to
67 distinguish rotated logs "%u" a unique number to resolve conflicts "%%"
68 translates to a single percent sign "%"
70 If no "%g" field has been specified and the file count is greater than one,
71 then the generation number will be added to the end of the generated filename,
74 Thus for example a pattern of "%t/java%g.log" with a count of 2 would typically
75 cause log files to be written on Solaris to /var/tmp/java0.log and
76 /var/tmp/java1.log whereas on Windows 95 they would be typically written to
77 C:\TEMP\java0.log and C:\TEMP\java1.log
79 Generation numbers follow the sequence 0, 1, 2, etc.
81 Normally the "%u" unique field is set to 0. However, if the FileHandler tries
82 to open the filename and finds the file is currently in use by another process
83 it will increment the unique number field and try again. This will be repeated
84 until FileHandler finds a file name that is not currently in use. If there is a
85 conflict and no "%u" field has been specified, it will be added at the end of
86 the filename after a dot. (This will be after any automatically added
89 Thus if three processes were all trying to log to fred%u.%g.txt then they might
90 end up using fred0.0.txt, fred1.0.txt, fred2.0.txt as the first file in their
93 Note that the use of unique ids to avoid conflicts is only guaranteed to work
94 reliably when using a local disk file system.
98 *java.util.logging.FileHandler()*
101 throws |java.io.IOException|
102 |java.lang.SecurityException|
104 Construct a default FileHandler. This will be configured entirely from
105 LogManager properties (or their default values).
108 *java.util.logging.FileHandler(String)*
110 public FileHandler(java.lang.String pattern)
111 throws |java.io.IOException|
112 |java.lang.SecurityException|
114 Initialize a FileHandler to write to the given filename.
116 The FileHandler is configured based on LogManager properties (or their default
117 values) except that the given pattern argument is used as the filename pattern,
118 the file limit is set to no limit, and the file count is set to one.
120 There is no limit on the amount of data that may be written, so use this with
123 pattern - the name of the output file
125 *java.util.logging.FileHandler(String,boolean)*
128 java.lang.String pattern,
130 throws |java.io.IOException|
131 |java.lang.SecurityException|
133 Initialize a FileHandler to write to the given filename, with optional append.
135 The FileHandler is configured based on LogManager properties (or their default
136 values) except that the given pattern argument is used as the filename pattern,
137 the file limit is set to no limit, the file count is set to one, and the append
138 mode is set to the given append argument.
140 There is no limit on the amount of data that may be written, so use this with
143 pattern - the name of the output file
144 append - specifies append mode
146 *java.util.logging.FileHandler(String,int,int)*
149 java.lang.String pattern,
152 throws |java.io.IOException|
153 |java.lang.SecurityException|
155 Initialize a FileHandler to write to a set of files. When (approximately) the
156 given limit has been written to one file, another file will be opened. The
157 output will cycle through a set of count files.
159 The FileHandler is configured based on LogManager properties (or their default
160 values) except that the given pattern argument is used as the filename pattern,
161 the file limit is set to the limit argument, and the file count is set to the
162 given count argument.
164 The count must be at least 1.
166 pattern - the pattern for naming the output file
167 limit - the maximum number of bytes to write to any one file
168 count - the number of files to use
170 *java.util.logging.FileHandler(String,int,int,boolean)*
173 java.lang.String pattern,
177 throws |java.io.IOException|
178 |java.lang.SecurityException|
180 Initialize a FileHandler to write to a set of files with optional append. When
181 (approximately) the given limit has been written to one file, another file will
182 be opened. The output will cycle through a set of count files.
184 The FileHandler is configured based on LogManager properties (or their default
185 values) except that the given pattern argument is used as the filename pattern,
186 the file limit is set to the limit argument, and the file count is set to the
187 given count argument, and the append mode is set to the given append argument.
189 The count must be at least 1.
191 pattern - the pattern for naming the output file
192 limit - the maximum number of bytes to write to any one file
193 count - the number of files to use
194 append - specifies append mode
196 *java.util.logging.FileHandler.close()*
198 public synchronized void close()
199 throws |java.lang.SecurityException|
205 *java.util.logging.FileHandler.publish(LogRecord)*
207 public synchronized void publish(java.util.logging.LogRecord record)
209 Format and publish a LogRecord.
212 record - description of the log event. A null record is silently ignored and is not