Java Reference
In-Depth Information
logger.disconnect();
}
else
System.out.println("cannot connect to file-based
logger");
logger
=
LoggerFact-
ory.newLogger(LoggerFactory.FILE);
if (logger.connect())
{
logger.log("test message #3");
logger.disconnect();
}
else
System.out.println("cannot connect to file-based
logger");
}
}
Followthesesteps(whichassumethattheJDKhasbeeninstalled)tocreatethe log-
ging package and TestLogger application, and to run this application:
1. Create a new directory and make this directory current.
2. Create a logging directory in the current directory.
3. Copy Listing 3-17 to a file named Logger.java in the logging directory.
4. Copy Listing3-18 toafilenamed LoggerFactory.java inthe logging
directory.
5. Copy Listing3-19 toafilenamed Console.java inthe logging directory.
6. Copy Listing 3-20 to a file named File.java in the logging directory.
7. Copy Listing3-21 toafilenamed TestLogger.java inthecurrentdirect-
ory.
8. Execute javac TestLogger.java ,whichalsocompiles logger 'ssource
files.
9. Execute java TestLogger .
After completing the final step, you should observe the following output from the
TestLogger application:
Search WWH ::




Custom Search