How to keep single file and overwrite the contents in the same file using log4cxx?

会有一股神秘感。 提交于 2019-12-02 07:14:59

This sample will solve your problem :

  log4j.rootLogger=debug, stdout, R

  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

  log4j.appender.R=org.apache.log4j.RollingFileAppender
  log4j.appender.R.File=example.log

  log4j.appender.R.MaxFileSize=100KB
  # Keep one backup file 
   log4j.appender.R.MaxBackupIndex = 0


  log4j.appender.R.layout=org.apache.log4j.PatternLayout
    log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

This will override the file contents in the same file.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!