Java Doc for LogContext.java in  » Development » Javolution » javolution » context » 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 » Development » Javolution » javolution.context 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javolution.context.Context
      javolution.context.LogContext

All known Subclasses:   javolution.testing.TestContext,  javolution.util.StandardLog,
LogContext
abstract public class LogContext extends Context (Code)

This class represents a context for object-based/thread-based logging capabilities.

The LogContext.DEFAULT default logging context is StandardLog StandardLog to leverage java.util.logging capabilities.

Logging can be temporarily modified on a thread or object basis. For example:[code] public static main(String[] args) { LogContext.enter(LogContext.NULL); // Temporarily disables logging. try { ClassInitializer.initializeAll(); // Initializes bootstrap, extensions and classpath classes. } finally { LogContext.exit(LogContext.NULL); // Goes back to default logging. } ... }[/code]

Applications may extend this base class to address specific logging requirements. For example:[code] // This class allows for custom logging of session events. public abstract class SessionLog extends LogContext { public static void start(Session session) { LogContext log = LogContext.current(); if (log instanceof SessionLog.Loggable) { ((SessionLog.Loggable)log).logStart(session); } else if (log.isInfoLogged()){ log.logInfo("Session " + session.id() + " started"); } } public static void end(Session session) { ... } public interface Loggable { void logStart(Session session); void logEnd(Session session); } }[/code]

The use of interfaces (such as Loggable above) makes it easy for any context to support customs logging events. For example:[code] class MyLog extends StandardLog implements SessionLog.Loggable, DatabaseLog.Loggable { ... // Specialized logging for session and database events. } MyLog myLog = new MyLog(); LogContext.enter(myLog); try { ... LogContext.info("Informative message"); // Standard logging. ... DatabaseLog.fail(transaction); // Database custom logging. ... SessionLog.start(session); // Session custom logging. ... } finally { LogContext.exit(myLog); }[/code]


author:
   Jean-Marie Dautelle
version:
   5.2, August 5, 2007


Field Summary
final public static  ClassCONSOLE
     Holds a context logging informative/warnings/errors events to the system console.
final public static  ConfigurableDEFAULT
     Holds the logging context default implementation (configurable, default value LogContext.STANDARD ).
final public static  ClassNULL
     Holds a logging context implementation ignoring logging events.
final public static  ClassSTANDARD
     Holds the logging context implementation forwarding log events to the root java.util.logging.Logger (default logging context).
final public static  ClassSYSTEM_OUT
     Holds a context logging messages to System.out.

Constructor Summary
protected  LogContext()
     Default constructor.

Method Summary
protected  voidenterAction()
    
public static  voiderror(Throwable error)
     Logs the specified error to the current logging context.
public static  voiderror(Throwable error, CharSequence message)
     Logs the specified error and error message to the current logging context.
public static  voiderror(Throwable error, String message)
     Equivalent to LogContext.error(Throwable,CharSequence) (for J2ME compatibility).
public static  voiderror(CharSequence message)
     Logs the specified error message to the current logging context.
final public static  voiderror(String message)
     Equivalent to LogContext.error(CharSequence) (for J2ME compatibility).
protected  voidexitAction()
    
public static  ContextgetCurrent()
     Returns the current logging context.
public static  LogContextgetDefault()
     Returns the default instance ( LogContext.DEFAULT implementation).
public static  voidinfo(CharSequence message)
     Logs the specified informative message.
public static  voidinfo(String message)
     Equivalent to LogContext.info(CharSequence) (for J2ME compatibility).
abstract public  booleanisErrorLogged()
     Indicates if errors are logged.
abstract public  booleanisInfoLogged()
     Indicates if informative messages are logged.
abstract public  booleanisWarningLogged()
     Indicates if warning messages are logged.
abstract public  voidlogError(Throwable error, CharSequence message)
     Logs the specified error.
final public  voidlogError(Throwable error, String message)
     Equivalent to LogContext.logError(Throwable,CharSequence) (for J2ME compatibility).
abstract public  voidlogInfo(CharSequence message)
     Logs the specified informative message.
final public  voidlogInfo(String message)
     Equivalent to LogContext.logInfo(CharSequence) (for J2ME compatibility).
abstract public  voidlogWarning(CharSequence message)
     Logs the specified warning message.
final public  voidlogWarning(String message)
     Equivalent to LogContext.logWarning(CharSequence) (for J2ME compatibility).
public static  voidwarning(CharSequence message)
     Logs the specified warning message to the current logging context.
public static  voidwarning(String message)
     Equivalent to LogContext.warning(CharSequence) (for J2ME compatibility).

Field Detail
CONSOLE
final public static Class CONSOLE(Code)
Holds a context logging informative/warnings/errors events to the system console.



DEFAULT
final public static Configurable DEFAULT(Code)
Holds the logging context default implementation (configurable, default value LogContext.STANDARD ).



NULL
final public static Class NULL(Code)
Holds a logging context implementation ignoring logging events.



STANDARD
final public static Class STANDARD(Code)
Holds the logging context implementation forwarding log events to the root java.util.logging.Logger (default logging context). The info/warning/error events are mapped to the info/warning/severe log levels respectively.



SYSTEM_OUT
final public static Class SYSTEM_OUT(Code)
Holds a context logging messages to System.out.




Constructor Detail
LogContext
protected LogContext()(Code)
Default constructor.




Method Detail
enterAction
protected void enterAction()(Code)



error
public static void error(Throwable error)(Code)
Logs the specified error to the current logging context.
Parameters:
  error - the error being logged.



error
public static void error(Throwable error, CharSequence message)(Code)
Logs the specified error and error message to the current logging context.
Parameters:
  error - the error being logged.
Parameters:
  message - the supplementary message.



error
public static void error(Throwable error, String message)(Code)
Equivalent to LogContext.error(Throwable,CharSequence) (for J2ME compatibility).



error
public static void error(CharSequence message)(Code)
Logs the specified error message to the current logging context.
Parameters:
  message - the error message being logged.



error
final public static void error(String message)(Code)
Equivalent to LogContext.error(CharSequence) (for J2ME compatibility).



exitAction
protected void exitAction()(Code)



getCurrent
public static Context getCurrent()(Code)
Returns the current logging context. If the current thread has not entered any logging context the LogContext.getDefault() is returned. the current logging context.



getDefault
public static LogContext getDefault()(Code)
Returns the default instance ( LogContext.DEFAULT implementation). the default instance.



info
public static void info(CharSequence message)(Code)
Logs the specified informative message.
Parameters:
  message - the informative message being logged.
See Also:   LogContext.logInfo(CharSequence)



info
public static void info(String message)(Code)
Equivalent to LogContext.info(CharSequence) (for J2ME compatibility).



isErrorLogged
abstract public boolean isErrorLogged()(Code)
Indicates if errors are logged. true if errors are logged;false otherwise.



isInfoLogged
abstract public boolean isInfoLogged()(Code)
Indicates if informative messages are logged. true if informative messages are logged;false otherwise.



isWarningLogged
abstract public boolean isWarningLogged()(Code)
Indicates if warning messages are logged. true if warnings message are logged;false otherwise.



logError
abstract public void logError(Throwable error, CharSequence message)(Code)
Logs the specified error.
Parameters:
  error - the error being logged or null if none.
Parameters:
  message - the associated message or null if none.



logError
final public void logError(Throwable error, String message)(Code)
Equivalent to LogContext.logError(Throwable,CharSequence) (for J2ME compatibility).



logInfo
abstract public void logInfo(CharSequence message)(Code)
Logs the specified informative message.
Parameters:
  message - the informative message being logged.



logInfo
final public void logInfo(String message)(Code)
Equivalent to LogContext.logInfo(CharSequence) (for J2ME compatibility).



logWarning
abstract public void logWarning(CharSequence message)(Code)
Logs the specified warning message.
Parameters:
  message - the warning message being logged.



logWarning
final public void logWarning(String message)(Code)
Equivalent to LogContext.logWarning(CharSequence) (for J2ME compatibility).



warning
public static void warning(CharSequence message)(Code)
Logs the specified warning message to the current logging context.
Parameters:
  message - the warning message being logged.
See Also:   LogContext.logWarning(CharSequence)



warning
public static void warning(String message)(Code)
Equivalent to LogContext.warning(CharSequence) (for J2ME compatibility).



Fields inherited from javolution.context.Context
final public static Context ROOT(Code)(Java Doc)

Methods inherited from javolution.context.Context
final public static Context enter(Context context)(Code)(Java Doc)
final public static Context enter(Class contextType)(Code)(Java Doc)
abstract protected void enterAction()(Code)(Java Doc)
public static Context exit()(Code)(Java Doc)
final public static void exit(Context ctx)(Code)(Java Doc)
abstract protected void exitAction()(Code)(Java Doc)
final AllocatorContext getAllocatorContext()(Code)(Java Doc)
public static Context getCurrent()(Code)(Java Doc)
final public Context getOuter()(Code)(Java Doc)
final public Thread getOwner()(Code)(Java Doc)
protected static void setCurrent(ConcurrentContext context)(Code)(Java Doc)
public String toString()(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) 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.