文档介绍:Java原生日志工具Logger参考 JDK自带日志类位于,同时在JDK安装目录的jre/,默认只进行控制台输出。使用JDK自带的日志处理比Log4J特别好的一点就是不需要导入任何第三方Jar。 简单示例1:import;import;lassTestLogger{publicstaticvoidmain(String[]args){ Loggerlog=("mylog"); (); Loggerlog1=("mylog"); ==log1);//true Loggerlog2=(""); (); ("111"); ("222"); ("sorry...");}}这个例子可直接跑,getLogger参数”mylog”为开发自己配置,如果当前没有名为”mylog”的Logger则会自动创建,如果已有则直接返回。从这个例子可以看出,日志级别是能动态设置的。简单示例2:import;import;import;import;lassLoggerUtil{publicstaticvoidconfig(){try{().readConfiguration(""));}catch(IOExceptionex){(,null,ex);}catch(SecurityExceptionex){(,null,ex);}}}这个例子演示如何通过LogManager来读取自己的配置文件。:       ############################################################# DefaultLoggingConfigurationFile##Youcanuseadifferentfilebyspecifyingafilename#withthesystemproperty.#Forexamplejava-######################################################################################################################### Globalproperties#############################################################"handlers"maseparatedlistoflogHandler#.#Notethattheseclassesmustbeonthesystemclasspath.#Bydefau