how can i configure a log4j.properties with a rootlogger = debug, stdout, logfile
and org.apache.httpclient = debug
which goes into the logfile but not the stdout?
raising the rootlogger to info is not acceptable as i have others package at the debug level.
To Enable or Disable Log4j Logging for an Instant Messaging Component. By default, log4j logging is used for all components for which logging information is generated. To disable log4j logging, set the logging level for the component to OFF in both log4j. conf and log4j.
The rootlogger is always the logger configured in the log4j. properties file, so every child logger used in the application inherits the configuration of the rootlogger . The logging levels are (from smaller to greater) : ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF .
To define a custom log level in code, use the Level. forName() method. This method creates a new level for the specified name. After a log level is defined you can log messages at this level by calling the Logger.
In the log4j.properties
file, add the line
log4j.logger.org.apache.httpclient=DEBUG, logfile
to direct the org.apache.httpclient
logger output to the logfile
appender.
Also include the line
log4j.additivity.org.apache.httpclient=false
to prevent the org.apache.httpclient
logger output going to the rootLogger
's appenders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With