- 浏览: 471263 次
- 性别:
- 来自: 杭州
-
文章分类
- 全部博客 (146)
- Maven (3)
- Quartz (10)
- Hessian (3)
- JDK (42)
- eclipse (4)
- 设计思想 (6)
- XML (8)
- JavaMail (1)
- Spring (11)
- mina (1)
- HsqlDb (1)
- Cache (2)
- Tool (6)
- 心情 (5)
- JQuery (0)
- Hadoop (5)
- Hbase (3)
- 自动构建 (7)
- JNDI (0)
- 代码赏析 (5)
- Oracle (1)
- Excel (4)
- Effective Java (5)
- JAXB (4)
- fdafasdf (1)
- ccc (0)
- web (3)
- concurrent (1)
- CVS (1)
- eclipse plugin (2)
- Apache (10)
最新评论
-
chxiaowu:
nice!
Quartz实现固定执行次数 -
zxjlwt:
学习了。http://surenpi.com
自定义ClassLoader -
kadlly:
public static final Logger log ...
Hessian 权限认证 -
spring_springmvc:
java程序语言学习教程 地址http://www.zuida ...
Java-Final -
liushuiwuyan:
[img][/img]
设计模式-单例
jdk自带有一个log日志,对于一般的使用,仅够了.
代码如下:
jdk自带的logging配置文件在jdk安装的lib目录下,这里需要重写。内容如下:
默认jdk日志只打印在控制台,我这里把jdk日志输出到文件中.
基本上和log4j的配置相差不多,jdk自带日志比较方便,项目不需要引入jar.
jdk的日志使用的是nio,其效率不会很差,一般使用比如日志记录,把日志写到文件中,把日志消息发送到日志服务中心等等.
我感觉这个还是挺好玩的,如果使用Applet等,或者jar包client需要记录一些日志等,不需要引入三方jar,项目全清新很多.
当然了一般一个公司只会选择一种日志系统,这个就看架构了,日志系统是很重要的一环。
代码如下:
package org.frame.base.logging; import java.util.logging.Level; import java.util.logging.Logger; /** * JDK自带的log挺好玩的 * * @author ycl * @version 1.0 2012-11-6 上午10:31:37 * @since 1.0 * */ public class JDKLog { static{ System.setProperty("java.util.logging.config.file", System.getProperty("user.dir")+"\\jdkLogging.properties"); System.out.println(System.getProperty("java.util.logging.config.file")); } private static Logger logger = Logger.getLogger("A组"); public static void main(String[] args) { logger.log(Level.INFO, "a雷兄嘿嘿"); logger.log(Level.WARNING, "去死"); logger.log(Level.WARNING, System.getProperty("java.util.logging.config.file")); } }
jdk自带的logging配置文件在jdk安装的lib目录下,这里需要重写。内容如下:
############################################################ # Default Logging Configuration File # # You can use a different file by specifying a filename # with the java.util.logging.config.file system property. # For example java -Djava.util.logging.config.file=myfile ############################################################ ############################################################ # Global properties ############################################################ # "handlers" specifies a comma separated list of log Handler # classes. These handlers will be installed during VM startup. # Note that these classes must be on the system classpath. # By default we only configure a ConsoleHandler, which will only # show messages at the INFO and above levels. handlers= java.util.logging.ConsoleHandler # To also add the FileHandler, use the following line instead. handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler # Default global logging level. # This specifies which kinds of events are logged across # all loggers. For any given facility this global level # can be overriden by a facility specific level # Note that the ConsoleHandler also has a separate level # setting to limit messages printed to the console. .level= INFO ############################################################ # Handler specific properties. # Describes specific configuration info for Handlers. ############################################################ # default file output is in user's home directory. XMLFormatter java.util.logging.FileHandler.pattern = D:\\fileTest.log java.util.logging.FileHandler.limit = 50000 java.util.logging.FileHandler.count = 1 java.util.logging.FileHandler.append = true java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter # Limit the message that are printed on the console to INFO and above. java.util.logging.ConsoleHandler.level = INFO java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter ############################################################ # Facility specific properties. # Provides extra control for each logger. ############################################################ # For example, set the com.xyz.foo logger to only log SEVERE # messages: com.xyz.foo.level = SEVERE
默认jdk日志只打印在控制台,我这里把jdk日志输出到文件中.
基本上和log4j的配置相差不多,jdk自带日志比较方便,项目不需要引入jar.
jdk的日志使用的是nio,其效率不会很差,一般使用比如日志记录,把日志写到文件中,把日志消息发送到日志服务中心等等.
我感觉这个还是挺好玩的,如果使用Applet等,或者jar包client需要记录一些日志等,不需要引入三方jar,项目全清新很多.
当然了一般一个公司只会选择一种日志系统,这个就看架构了,日志系统是很重要的一环。
发表评论
-
Java Application Cache
2016-09-27 19:25 903Application Cache is used very ... -
Java 字符串分词
2015-01-02 14:43 1771在Java的世界里有个类型 ... -
jdk 1.6 新特性,集成Groovy, 性能很差
2014-04-02 14:27 1300性能都是相对的,如果调用量不是很大的话,可以忽略,毕竟使用为主 ... -
Fake Code easy implements
2014-04-01 15:41 1043package org.miniframe.modules ... -
JDK regex 用法及用途
2014-03-31 15:48 1235查找 Boolean flag = pattern.mat ... -
生产者消费者(四)
2014-03-04 12:32 1163需求: 多个生产者不断的生产产品,多个消费者不断的消费产品,仓 ... -
生产者消费者(三)
2014-03-04 10:59 974需求: 多个生产者不断的生产产品,多个消费者不断的消费产品,仓 ... -
生产者消费者(二)
2014-03-03 15:40 711需求: 多个生产者不断的生产产品,多个消费者不断的消费产品,仓 ... -
生产者消费者模式(一)
2014-02-28 14:30 1045需求: 多个生产者不断的生产产品,多个消费者不断的消费产品,仓 ... -
查看Class文件使用的JDK版本
2013-10-30 14:17 1132由于JDK一般是向下兼容的,所以有时候本地的JDK版本比类库的 ... -
Java源代码转码
2012-12-20 17:22 1336现在中国的项目很多,编码无非是UTF-8,GBK,GB2312 ... -
Tomcat集成OSGI,并通过JNDI开放Web调用
2012-12-03 11:22 3171Tomcat集成OSGi,首先要选择OSGI服务器,我这里采用 ... -
java.util.*
2012-11-06 14:23 1394java.util 工具包,灰常的有用,有机会一定要研读源码。 ... -
java.util.concurrent.*
2012-11-02 10:38 17901. java.util.concurrent.ArrayBl ... -
java.util.rt.*
2012-10-31 13:51 11271. java.util.HashMap 散列表,主要是以离散 ... -
巧秒设计方法,不返回null
2016-09-27 19:32 766/** * {@inheritDoc} * ... -
java doc 代码文档
2012-07-13 13:58 1346对于代码规范不解释了,网上很多。 在编写代码的时候,有一点灰 ... -
接口与抽象类
2012-07-11 16:53 11351. 接口设计必谨慎,除非业务变更,否则打死不能动接口。[不变 ... -
JVM优化机制好诡异
2012-04-20 08:43 1482long i[] = new long[1000000]; ... -
JVM优化机制好诡异
2016-09-27 19:32 578long i[] = new long[100000 ...
评论