hyljava

          log4j的簡單配置

           首先導入兩個包:  commons-logging.jar  log4j-1.2.12.jar

             在src下編寫3個 properties文件

          1.log4j.properties 下面是內容


          ##LOGGERS

          #define a logger
          log4j.rootLogger=INFO,console,file

          ##APPENDERS
          #define an appender named console
          log4j.appender.console=org.apache.log4j.ConsoleAppender
          #define an appender named file
          log4j.appender.file=org.apache.log4j.RollingFileAppender
          log4j.appender.file.File=d:/demo_log.txt
          #set the log's size
          log4j.appender.file.MaxFileSize=1000KB
          log4j.appender.file.MaxBackupIndex=20

          ##LAYOUTS
          #assign a SimpleLayout to console appender
          log4j.appender.console.layout=org.apache.log4j.SimpleLayout
          #assign a PatternLayout to file appender
          log4j.appender.file.layout=org.apache.log4j.PatternLayout
          log4j.appender.file.layout.ConversionPattern=[%-5p][%d{yyyy-MM-dd HH:mm:ss}]%m%n

           

          2.
              simplelog.properties下面是內容


          log.apache.commons.logging.simplelog.defaultlog=info

          3.
              commons-logging.properties下面是內容

          ##set Log as Log4J
          org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

           

           

          posted on 2012-05-28 19:04 何云隆 閱讀(317) 評論(0)  編輯  收藏 所屬分類: HibernateStruts1spring

          主站蜘蛛池模板: 武乡县| 共和县| 澄江县| 临桂县| 台南县| 临湘市| 巴南区| 松滋市| 乐平市| 溧水县| 互助| 琼中| 泌阳县| 大丰市| 通河县| 旬邑县| 清新县| 唐海县| 西昌市| 达拉特旗| 南充市| 无极县| 新建县| 年辖:市辖区| 邵阳县| 疏附县| 泽州县| 茌平县| 大姚县| 黄平县| 泾源县| 陇川县| 本溪| 华池县| 荔波县| 青川县| 揭东县| 德化县| 丹东市| 西青区| 井研县|