Flush File Handler and Logger : Log Handler « Log « Java Tutorial

Java Tutorial
1. Language
2. Data Type
3. Operators
4. Statement Control
5. Class Definition
6. Development
7. Reflection
8. Regular Expressions
9. Collections
10. Thread
11. File
12. Generics
13. I18N
14. Swing
15. Swing Event
16. 2D Graphics
17. SWT
18. SWT 2D Graphics
19. Network
20. Database
21. Hibernate
22. JPA
23. JSP
24. JSTL
25. Servlet
26. Web Services SOA
27. EJB3
28. Spring
29. PDF
30. Email
31. J2ME
32. J2EE Application
33. XML
34. Design Pattern
35. Log
36. Security
37. Apache Common
38. Ant
39. JUnit
Java
Java Source Code / Java Documentation
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 Tutorial » Log » Log Handler 
35. 5. 14. Flush File Handler and Logger
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

public class Main {
  public static void main(String[] argsthrows Exception {
    FileHandler handler = null;
    Logger logger = Logger.getLogger("logging");

    handler = new FileHandler("pattern"10002);
    logger.addHandler(handler);
    LogRecord record = new LogRecord(Level.INFO, "Logged in a file...");
    logger.log(record);
    handler.flush();
    handler.close();
  }
}
35. 5. Log Handler
35. 5. 1. Use ConsoleHandler
35. 5. 2. Using FileHandler to log a message
35. 5. 3. Add Multiple Handlers to a logger
35. 5. 4. How to write custom handler
35. 5. 5. Stream Handler
35. 5. 6. Memory Handler Demo
35. 5. 7. Socket Handler Demo
35. 5. 8. Using Regular Expressions based on StreamHandler
35. 5. 9. Writing Log Records to a Log File
35. 5. 10. A file handler that appends.
35. 5. 11. Writing Log Records to Standard Error
35. 5. 12. Writing Log Records Only After a Condition Occurs
35. 5. 13. Create a memory handler with a memory of 100 records and dumps the records into the file my.log
35. 5. 14. Flush File Handler and Logger
35. 5. 15. The Patterns in FileHandler
35. 5. 16. Limiting the Size of a Log File
35. 5. 17. Limiting the Size of a Log by Using a Rotating Sequence of Files
35. 5. 18. Use Logger with simple formatter and FileHander
35. 5. 19. Alternate XML by using FileHandler
35. 5. 20. Window Handler: display log message in a window(JFrame)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.