简体   繁体   中英

How to disable log4j2 Configuration?

How can i disable whole configuration?

I tried setting Root Status to off, but then it is not writing into log files and the log files are getting generated as empty files.

I don't want log files to be generated if root status is off... Please suggest if there is any way.

You'll need to set a property on your FileAppender to create the file on demand.

See createOnDemand here: https://logging.apache.org/log4j/2.x/manual/appenders.html

An example:

<RollingFile name="RollingLogFile"
            fileName="logs/rolling.log"
            filePattern="logs/rolling-%d{yyyy-MM-dd-HH-mm}.log.gz"
            createOnDemand="true">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM