javalog4jfileappender

log4j:Appender to print the log Statements


Hello sir: When server is started ,the log files print the output statement..how can i print the log files in my own file?


Solution

  • Configure a log4j properties file with file appender. Something like this -

    log4j.rootLogger=WARN, fileAppender
    log4j.logger.myPackage=DEBUG, fileAppender
    log4j.additivity.myPackage=false
    log4j.appender.fileAppender=org.apache.log4j.RollingFileAppender
    log4j.appender.fileAppender.File= C://Myfile.log
    log4j.appender.fileAppender.MaxFileSize=1024KB 
    log4j.appender.fileAppender.MaxBackupIndex=5 
    log4j.appender.fileAppender.layout = org.apache.log4j.PatternLayout
    log4j.appender.fileAppender.layout.ConversionPattern=%d [%t] %-5p %c - %m%n