loggingklocwork

Klocwork logs file size and rotation


Did anyone find where and how to configure the log level and rotation of the klocwork.log? The default is "INFO" and no rotation, so after a while, the file becomes HUGE!
The support site documentation is very shallow


Solution

  • After a while I found an answer:

    Instruction: 1. stop the klocwork server 2. remove the current klocwork.log from /log to a backup directory for storage 3. start the klocwork server 4 Open the logging configuration web page by adding #logconf to the end of the Klocwork portal URL in the browser after login. For example: http://klocwork_server1:8080/review/insight-review.html#logconf

    When "Logging Configuration" is open, replace everything in it with the text below:

    log4j.defaultInitOverride = false
    log4j.rootLogger=INFO,MAIN_LOG
    log4j.appender.MAIN_LOG.File=<KW server installed directory>/projects_root/logs/klocwork.log 
    log4j.appender.MAIN_LOG=org.apache.log4j.RollingFileAppender
    log4j.appender.MAIN_LOG.layout=org.apache.log4j.PatternLayout
    log4j.appender.MAIN_LOG.DatePattern='.'yyyy-MM-dd
    log4j.appender.MAIN_LOG.MaxFileSize=10MB
    log4j.appender.MAIN_LOG.MaxBackupIndex=3
    log4j.appender.MAIN_LOG.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c %x - %m%n
    log4j.appender.MAIN_LOG.append=true
    

    NOTE: Replace with your installed directory.

    Click the Apply button at the right bottom. The log rotation will take effect immediately.