在配置文件中应该怎么写才能让每次输出日志的时候输出错误发生位置,错误内容,错误时间,时间呀.还想请问下在LOG4J中能不能通过配置文件实现让日志每天输出一次?

解决方案 »

  1.   

    #### Use two appenders, one to log to console, another to log to a file
    log4j.rootCategory=debug,stdout, R
    # Print only messages of priority WARN or higher for your category
    log4j.category.your.category.name=WARN
    #### First appender writes to console
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    # Pattern to output the caller's file name and line number.
    log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
    ########################
    # JDBC Appender
    #### Second appender writes to a file
    log4j.appender.R=org.apache.log4j.RollingFileAppender
    log4j.appender.R.File=daily.log
    # Control the maximum log file size
    log4j.appender.R.MaxFileSize=2048KB
    # Archive log files (one backup file here)
    log4j.appender.R.MaxBackupIndex=50
    log4j.appender.R.layout=org.apache.log4j.PatternLayout
    log4j.appender.R.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %l %d - %m%n日志 是程序里 log.info .err 写入的 ,在程序控制
      

  2.   

    这个问题基本上解决了,还想问下通过LOG4J的配置文件能不能实现让日志文件一天输出一次??
      

  3.   

    我把我的例子传给你,你自己分析一下就OK了
    [email protected]
      

  4.   

    log4j能不能按时间出入日志文件啊  比如20060422 今天的日志文件名就是20060422 明天的就是
    20060423
      

  5.   

    那LOG日志的输出路径怎么指定呀???log4j.appender.R.file=Log.log  为什么每次WEB工程输出的都是和我Eclipse可执行文件平级呀,如何才能指定日志的输出路径呀,还要在有劳各位,不好意思
      

  6.   

    log4j.appender.R.File=daily.log
    看这
    建立一个目录 如 abc
    log4j.appender.R.File=abc/daily.log