My log4j.properties file looks like this:
# Root logger option
log4j.rootLogger=DEBUG, file
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=/home/user/logs/myapp.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%5p [%c] %m%n
log4j.logger.org.apache.http=DEBUG
The file myapp.log is created, and my http requests are executing, but the log file remains empty and I have no idea why.
edit: in the class that is using HttpClient, I was able to log messages there. So it makes me think the log4j.logger.org.apache.http line is wrong even though that’s what the documentation on http://hc.apache.org/ tells you to do.
I had a similar problem in my Grails app and it required that I declare my config in a specific order. I had to declare my debug filters, my appenders and then my root loggers in that specific order. I included my config below for your reference. I hope this helps you.