Java Doc for FileHandler.java in  » Apache-Harmony-Java-SE » java-package » java » util » logging » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.util.logging 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.logging.Handler
      java.util.logging.StreamHandler
         java.util.logging.FileHandler

FileHandler
public class FileHandler extends StreamHandler (Code)
A FileHandler is a Handler that writes logging events to one or more files.

If multiple files are used, when a given amount of data has been written to one file, this file is closed, and the next file is opened. The names of these files are generated by the given name pattern, see below for details. When all the files have all been filled the Handler returns to the first one and goes through the set again.

FileHandler defines the following configuration properties, which are read by the LogManager on initialization. If the properties have not been specified then defaults will be used. The properties and defaults are as follows:

  • java.util.logging.FileHandler.append - If true then this FileHandler appends to a file's existing content, if false it overwrites it. Default is false.
  • java.util.logging.FileHandler.count - the number of output files to rotate. Default is 1.
  • java.util.logging.FileHandler.filter - the name of the Filter class. No Filter is used by default.
  • java.util.logging.FileHandler.formatter - the name of the Formatter class. Default is java.util.logging.XMLFormatter.
  • java.util.logging.FileHandler.encoding - the name of the character set encoding. Default is the encoding used by the current platform.
  • java.util.logging.FileHandler.level - the log level for this Handler. Default is Level.ALL.
  • java.util.logging.FileHandler.limit - the limit at which no more bytes should be written to the current file. Default is no limit.
  • java.util.logging.FileHandler.pattern - the pattern for the name of log files. Default is "%h/java%u.log".

The name pattern is a String that can contain some of the following sub-strings, which will be replaced to generate the output file names:

  • "/" represents the local path separator
  • "%g" represents the generation number used to enumerate log files
  • "%h" represents the home directory of the current user, which is specified by the "user.home" system property
  • "%t" represents the system's temporary directory
  • "%u" represents a unique number added to the file name if the original file required is in use
  • "%%" represents the percent sign character '%'

The generation numbers, denoted by "%g" in the filename pattern will be created in ascending numerical order from 0, i.e. 0,1,2,3... If "%g" was not present in the pattern and more than one file is being used then a dot and a generation number is appended to the filename at the end. This is equivalent to appending ".%g" to the pattern.

The unique identifier, denoted by "%u" in the filename pattern will always be 0 unless the FileHandler is unable to open the file. In that case 1 is tried, then 2, and so on until a file is found that can be opened. If "%u" was not present in the pattern but a unique number is required then a dot and a unique number is added to the end of the filename, equivalent to appending ".%u" to the pattern.


Inner Class :static class MeasureOutputStream extends OutputStream

Field Summary
 StringfileName
    
 FileLocklock
    
 intuniqueID
    

Constructor Summary
public  FileHandler()
    
public  FileHandler(String pattern)
     Construct a FileHandler, the given name pattern is used as output filename, the file limit is set to zero(no limit), and the file count is set to one, other configuration using LogManager properties or their default value This handler write to only one file and no amount limit.
public  FileHandler(String pattern, boolean append)
     Construct a FileHandler, the given name pattern is used as output filename, the file limit is set to zero(i.e.
public  FileHandler(String pattern, int limit, int count)
     Construct a FileHandler, the given name pattern is used as output filename, the file limit is set to given limit argument, and the file count is set to given count argument, other configuration using LogManager properties or their default value This handler is configured to write to a rotating set of count files, when the limit of bytes has been written to one output file, another file will be opened instead.
public  FileHandler(String pattern, int limit, int count, boolean append)
     Construct a FileHandler, the given name pattern is used as output filename, the file limit is set to given limit argument, the file count is set to given count argument, and the append mode is set to given append argument, other configuration using LogManager properties or their default value This handler is configured to write to a rotating set of count files, when the limit of bytes has been written to one output file, another file will be opened instead.

Method Summary
public  voidclose()
     Flush and close all opened files.
 voidfindNextGeneration()
    
public  voidpublish(LogRecord record)
    

Field Detail
fileName
String fileName(Code)



lock
FileLock lock(Code)



uniqueID
int uniqueID(Code)




Constructor Detail
FileHandler
public FileHandler() throws IOException(Code)
Construct a FileHandler using LogManager properties or their default value
throws:
  IOException - if any IO exception happened
throws:
  SecurityException - if security manager exists and it determines that caller doesnot have the required permissions to control this handler,required permissions includeLogPermission("control") and other permissionlike FilePermission("write"), etc.



FileHandler
public FileHandler(String pattern) throws IOException(Code)
Construct a FileHandler, the given name pattern is used as output filename, the file limit is set to zero(no limit), and the file count is set to one, other configuration using LogManager properties or their default value This handler write to only one file and no amount limit.
Parameters:
  pattern - the name pattern of output file
throws:
  IOException - if any IO exception happened
throws:
  SecurityException - if security manager exists and it determines that caller doesnot have the required permissions to control this handler,required permissions includeLogPermission("control") and other permissionlike FilePermission("write"), etc.
throws:
  NullPointerException - if the pattern is null.
throws:
  IllegalArgumentException - if the pattern is empty.



FileHandler
public FileHandler(String pattern, boolean append) throws IOException(Code)
Construct a FileHandler, the given name pattern is used as output filename, the file limit is set to zero(i.e. no limit applies), the file count is initialized to one, and the value of append becomes the new instance's append mode. Other configuration is done using LogManager properties. This handler write to only one file and no amount limit.
Parameters:
  pattern - the name pattern of output file
Parameters:
  append - the append mode
throws:
  IOException - if any IO exception happened
throws:
  SecurityException - if security manager exists and it determines that caller doesnot have the required permissions to control this handler,required permissions includeLogPermission("control") and other permissionlike FilePermission("write"), etc.
throws:
  NullPointerException - if the pattern is null.
throws:
  IllegalArgumentException - if the pattern is empty.



FileHandler
public FileHandler(String pattern, int limit, int count) throws IOException(Code)
Construct a FileHandler, the given name pattern is used as output filename, the file limit is set to given limit argument, and the file count is set to given count argument, other configuration using LogManager properties or their default value This handler is configured to write to a rotating set of count files, when the limit of bytes has been written to one output file, another file will be opened instead.
Parameters:
  pattern - the name pattern of output file
Parameters:
  limit - the data amount limit in bytes of one output file, cannot lessthan one
Parameters:
  count - the maximum number of files can be used, cannot less than one
throws:
  IOException - if any IO exception happened
throws:
  SecurityException - if security manager exists and it determines that caller doesnot have the required permissions to control this handler,required permissions includeLogPermission("control") and other permissionlike FilePermission("write"), etc.
throws:
  NullPointerException - if pattern is null.
throws:
  IllegalArgumentException - if count<1, or limit<0



FileHandler
public FileHandler(String pattern, int limit, int count, boolean append) throws IOException(Code)
Construct a FileHandler, the given name pattern is used as output filename, the file limit is set to given limit argument, the file count is set to given count argument, and the append mode is set to given append argument, other configuration using LogManager properties or their default value This handler is configured to write to a rotating set of count files, when the limit of bytes has been written to one output file, another file will be opened instead.
Parameters:
  pattern - the name pattern of output file
Parameters:
  limit - the data amount limit in bytes of one output file, cannot lessthan one
Parameters:
  count - the maximum number of files can be used, cannot less than one
Parameters:
  append - the append mode
throws:
  IOException - if any IO exception happened
throws:
  SecurityException - if security manager exists and it determines that caller doesnot have the required permissions to control this handler,required permissions includeLogPermission("control") and other permissionlike FilePermission("write"), etc.
throws:
  NullPointerException - if pattern is null.
throws:
  IllegalArgumentException - if count<1, or limit<0




Method Detail
close
public void close()(Code)
Flush and close all opened files.
throws:
  SecurityException - if security manager exists and it determines that caller doesnot have the required permissions to control this handler,required permissions includeLogPermission("control") and other permissionlike FilePermission("write"), etc.



findNextGeneration
void findNextGeneration()(Code)



publish
public void publish(LogRecord record)(Code)
Publish a LogRecord
Parameters:
  record - the log record to be published



Methods inherited from java.util.logging.StreamHandler
void close(boolean closeStream)(Code)(Java Doc)
public void close()(Code)(Java Doc)
public void flush()(Code)(Java Doc)
void internalSetOutputStream(OutputStream newOs)(Code)(Java Doc)
public boolean isLoggable(LogRecord record)(Code)(Java Doc)
public synchronized void publish(LogRecord record)(Code)(Java Doc)
public void setEncoding(String encoding) throws SecurityException, UnsupportedEncodingException(Code)(Java Doc)
protected void setOutputStream(OutputStream os)(Code)(Java Doc)

Methods inherited from java.util.logging.Handler
abstract public void close()(Code)(Java Doc)
abstract public void flush()(Code)(Java Doc)
public String getEncoding()(Code)(Java Doc)
public ErrorManager getErrorManager()(Code)(Java Doc)
public Filter getFilter()(Code)(Java Doc)
public Formatter getFormatter()(Code)(Java Doc)
public Level getLevel()(Code)(Java Doc)
void initProperties(String defaultLevel, String defaultFilter, String defaultFormatter, String defaultEncoding)(Code)(Java Doc)
void internalSetEncoding(String newEncoding) throws UnsupportedEncodingException(Code)(Java Doc)
void internalSetFormatter(Formatter newFormatter)(Code)(Java Doc)
public boolean isLoggable(LogRecord record)(Code)(Java Doc)
void printInvalidPropMessage(String key, String value, Exception e)(Code)(Java Doc)
abstract public void publish(LogRecord record)(Code)(Java Doc)
protected void reportError(String msg, Exception ex, int code)(Code)(Java Doc)
public void setEncoding(String encoding) throws SecurityException, UnsupportedEncodingException(Code)(Java Doc)
public void setErrorManager(ErrorManager em)(Code)(Java Doc)
public void setFilter(Filter newFilter)(Code)(Java Doc)
public void setFormatter(Formatter newFormatter)(Code)(Java Doc)
public void setLevel(Level newLevel)(Code)(Java Doc)

Methods inherited from java.lang.Object
protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object object)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final public Class<? extends Object> getClass()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
final public void notify()(Code)(Java Doc)
final public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final public void wait(long millis, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait(long millis) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.