Rolling log Files & removing old log files

前端 未结 6 2010
长发绾君心
长发绾君心 2021-02-07 03:15

I am working on a Java SOAP based webservice application where I am writing stdout to a text file as log for our reference. That file is growing enormously, so I need to check f

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-07 03:47

    Most logging frameworks provide what you're looking for. In logback you should be able to achieve it by properly configuring a RollingFileAppender:

    RollingFileAppender extends FileAppender with the capability to rollover log files. For example, RollingFileAppender can log to a file named log.txt file and, once a certain condition is met, change its logging target to another file.

    and

    RollingPolicy is responsible for the rollover procedure which involves file moving and renaming.

    http://logback.qos.ch/manual/appenders.html

提交回复
热议问题