Need a working example of configuring log4j RollingFileAppender via properties -


i using log4j logging, , property file configuration. currently, log files big (3.5 gb large log file). think need use rollingfileappender - when log file continues grow overly large. believe have misconfigured it; have working example of configuring rollingfileappender?

for record, current configuration looks this:

log4j.appender.main_log.file=${catalina.base}/logs/webtop.log log4j.appender.main_log=org.apache.log4j.rollingfileappender log4j.appender.main_log.layout=com.mycompany.util.log.log4jsimplelayout log4j.appender.main_log.datepattern='.'yyyy-mm-dd log4j.appender.main_log.maxfilesize=10mb log4j.appender.main_log.maxbackupindex=99 log4j.appender.main_log.append=true log4j.rootcategory=all, main_log 

an alternative rollingfileappender fine solution.

i believe have misconfigured it; have working example of configuring rollingfileappender?

this seems work fine me @mcherm. see below.

are sure using log4j.properties think are? try changing .file path see if log output goes new file. version of log4j using? i'm running 1.2.15.

hope helps.


i created following test program:

package com.j256.ormlite; import org.apache.log4j.logger; public class foo {     private static logger logger = logger.getlogger(foo.class);     public static void main(string[] args) {         (int x = 0; x < 10000000; x++) {             logger.error("goodness shouldn't happening right here!!!!");         }     } } 

my log4j.properties file holds:

log4j.appender.main_log=org.apache.log4j.rollingfileappender log4j.appender.main_log.file=${catalina.base}/logs/webtop.log log4j.appender.main_log.layout=com.j256.ormlite.log4jsimplelayout log4j.appender.main_log.maxfilesize=10mb log4j.appender.main_log.maxbackupindex=5 log4j.appender.main_log.append=true log4j.rootcategory=all, main_log 

notice removed datepattern wasn't valid rollingfileappender. layout is:

package com.j256.ormlite; import org.apache.log4j.spi.loggingevent; public class log4jsimplelayout extends org.apache.log4j.layout {     @override     public string format(loggingevent event) {         return "log message = " + event.getmessage().tostring() + "\n";     }     @override     public boolean ignoresthrowable() {         return true;     }     public void activateoptions() {     } } 

running -dcatalina.base=/tmp/ files in /tmp/logs/ go index #5 , 10mb in size. if tune maxfilesize or maxbackupindex, adjusts appropriately.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -