开发者

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

开发者 https://www.devze.com 2023-02-22 10:34 出处:网络
In my application , Multiple threads log the data in the same file .if the file size exceeds the limit , then i have to delete the particul开发者_开发知识库ar record in file and move every contents up

In my application , Multiple threads log the data in the same file .if the file size exceeds the limit , then i have to delete the particul开发者_开发知识库ar record in file and move every contents upwards.

can I do this in Log4cxx?if so ,reply your thoughts..

Thanks..


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消