| Putting it together: |
|
// get a logger instance named "com.foo" Logger logger = Logger.getInstance("com.foo"); // Now set its level. logger.setLevel(Level.INFO); Logger barLogger = Logger.getInstance("com.foo.Bar"); // This request is enabled, because WARN >= INFO. logger.warn("Low fuel level."); // This request is disabled, because DEBUG < INFO. logger.debug("Starting search for nearest gas station."); // The logger instance barLogger, named "com.foo.Bar", // will inherit its level from the logger named // "com.foo" Thus, the following request is enabled // because INFO >= INFO. barLogger.info("Located nearest gas station."); // This request is disabled, because DEBUG < INFO. barLogger.debug("Exiting gas station search"); |
Underline for the level of the logging statement and italics for the inherited level of the relevant logger.
| GET THE DOCS DIRECTLY FROM THE DEVELOPER |
| For up to date and detailed log4j documentation directly from the developer please consider The complete log4j manual. |