4 Replies Latest reply on Apr 17, 2009 3:37 PM by 807588

    How to disable log4j via configuration file

    807588
      Howdy,

      I am using the quartz library which uses log4j, how can I disable log4j in my release version? where can I find a sample configuration file to disable log4j?

      TBH i am not sure if its actually running as i am not pointing it to config, i get these warnings:

      log4j:WARN No appenders could be found for logger (org.quartz.simpl.SimpleThreadPool).
      log4j:WARN Please initialize the log4j system properly.

      But I would prefer to just disable it all together (or initialize it correctly and make it do nothing)...so I am looking for how I can accomplish this. I've read over the docs here:

      http://logging.apache.org/log4j/1.2/manual.html

      They are a bit long winded for what I need to do so I might have missed it, but i am just looking for how to structure a minimal con fig file to properly initialize log4j and prevent it from logging anything
        • 1. Re: How to disable log4j via configuration file
          694568
          You have to create a log4j.properties file and place that file in the classpath of your application. The content of this file should be similar to the contents posted below.
          log4j.debug=TRUE
          log4j.rootLogger=INFO, R
          log4j.appender.R=org.apache.log4j.RollingFileAppender
          log4j.appender.R.File=C:/apache-tomcat-5.5.27/logs/testlog.log
          log4j.appender.R.MaxFileSize=100KB
          log4j.appender.R.MaxBackupIndex=5
          log4j.appender.R.layout=org.apache.log4j.PatternLayout
          log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss.SSSS} %p %t %c - %m%n
          This should avoid getting those warnings and instead create a log file for you.
          • 2. Re: How to disable log4j via configuration file
            807588
            That worked perfect, thankyou!

            Now quick question, how can I modify this to prevent logging from occuring? It seems as if I set log4j.debug=FALSE nothing is logged, is that all thats required? Also how can i specify a null appender? I dont want log4j to attempt to log to a file on an end users system
            • 3. Re: How to disable log4j via configuration file
              694568
              tiburblium wrote:
              Now quick question, how can I modify this to prevent logging from occuring? It seems as if I set log4j.debug=FALSE nothing is logged, is that all thats required?
              set rootLogger to OFF if you intend to turn off logging, something like this.
              log4j.rootLogger=OFF, R
              Also how can i specify a null appender? I dont want log4j to attempt to log to a file on an end users system
              log file is not created on the end users system. It is created in the app server where the application is running. Setting rootLogger to OFF should take care of your problem as nothing will be logged.
              • 4. Re: How to disable log4j via configuration file
                807588
                Brilliant, thank you!