I have configured a project with Log4j. I have configured log4j using log4.properties file.
While the test runs it creates the myLog.log file but nothing is written to the log file.
Appender we are using as RollingFileAppender and log4j.rootLogger=DEBUG.
Can any one suggest what might be causing this problem?
Here is log4j.properties for the project.
log4j.rootLogger= DEBUG, ConsoleAppender, Rolling
log4j.appender.ConsoleAppender=org.apache.log4j.ConsoleAppender
log4j.appender.ConsoleAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ConsoleAppender.layout.ConversionPattern=%d %-2p %c.%M(): %m%n
log4j.appender.Rolling=org.apache.log4j.RollingFileAppender
log4j.appender.Rolling.MaxFileSize=5MB
log4j.appender.Rolling.MaxBackupIndex=2
log4j.appender.Rolling.File=D:\Logs\myProj.log
log4j.appender.Rolling.layout = org.apache.log4j.PatternLayout
log4j.appender.Rolling.layout.ConversionPattern=%d %-4p %c.%M(): %m%n
## Following two lines have been removed now.
log4j.logger.com=WARN
log4j.logger.org=WARN
Received Log in the log file :
2012-01-16 22:02:08,534 DEBUG org.apache.http.headers.receiveResponseHeader(): << content-type: application/json; charset=UTF-8
2012-01-16 22:02:08,534 DEBUG org.apache.http.headers.receiveResponseHeader(): << connection: close
2012-01-16 22:02:08,534 DEBUG org.apache.http.headers.receiveResponseHeader(): << content-length: 236
2012-01-16 22:02:08,550 DEBUG org.apache.http.headers.receiveResponseHeader(): << server: httpd.js
2012-01-16 22:02:08,550 DEBUG org.apache.http.headers.receiveResponseHeader(): << date: Tue, 17 Jan 2012 03:02:06 GMT
2012-01-16 22:02:08,566 DEBUG org.apache.http.wire.wire(): << "{"name":"clickElement","sessionId":"2fad55cf-670e-44f3-ab60-7d2f76f641e6","status":0,"value":"This action is final and cannot be undone?"}"
2012-01-16 22:02:08,566 DEBUG org.apache.http.impl.conn.DefaultClientConnection.shutdown(): Connection shut down
2012-01-16 22:02:08,566 DEBUG org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager.releaseConnection(): Released connection is not reusable.
2012-01-16 22:02:08,566 DEBUG org.apache.http.impl.conn.tsccm.ConnPoolByRoute.freeEntry(): Releasing connection [HttpRoute[{}->http://127.0.0.1:7055]][null]
2012-01-16 22:02:08,566 DEBUG org.apache.http.impl.conn.tsccm.ConnPoolByRoute.notifyWaitingThread(): Notifying no-one, there are no waiting threads
2012-01-16 22:02:10,566 DEBUG org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager.getConnection(): Get connection: HttpRoute[{}->http://127.0.0.1:7055], timeout = 120000
2012-01-16 22:02:10,566 DEBUG org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(): [HttpRoute[{}->http://127.0.0.1:7055]] total kept alive: 0, total issued: 0, total allocated: 0 out of 2000
2012-01-16 22:02:10,566 DEBUG org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getFreeEntry(): No free connections [HttpRoute[{}->http://127.0.0.1:7055]][null]
2012-01-16 22:02:10,566 DEBUG org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(): Available capacity: 2000 out of 2000 [HttpRoute[{}->http://127.0.0.1:7055]][null]
2012-01-16 22:02:10,581 DEBUG org.apache.http.impl.conn.tsccm.ConnPoolByRoute.createEntry(): Creating new connection [HttpRoute[{}->http://127.0.0.1:7055]]
2012-01-16 22:02:10,597 DEBUG org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(): Connecting to 127.0.0.1:7055
2012-01-16 22:02:10,597 DEBUG org.apache.http.client.protocol.RequestAddCookies.process(): CookieSpec selected: best-match
2012-01-16 22:02:10,597 DEBUG org.apache.http.client.protocol.RequestAuthCache.process(): Auth cache not set in the context
2012-01-16 22:02:10,597 DEBUG org.apache.http.impl.client.DefaultHttpClient.tryExecute(): Attempt 1 to execute request
2012-01-16 22:02:10,597 DEBUG org.apache.http.impl.conn.DefaultClientConnection.sendRequestHeader(): Sending request: GET /hub/session/2fad55cf-670e-44f3-ab60-7d2f76f641e6/alert_text HTTP/1.1
2012-01-16 22:02:10,597 DEBUG org.apache.http.wire.wire(): >> "GET /hub/session/2fad55cf-670e-44f3-ab60-7d2f76f641e6/alert_text HTTP/1.1[\r][\n]"
2012-01-16 22:02:10,597 DEBUG org.apache.http.wire.wire(): >> "Accept: application/json, image/png[\r][\n]"
2012-01-16 22:02:10,597 DEBUG org.apache.http.wire.wire(): >> "Host: 127.0.0.1:7055[\r][\n]"
2012-01-16 22:02:10,597 DEBUG org.apache.http.wire.wire(): >> "Connection: Keep-Alive[\r][\n]"
2012-01-16 22:02:10,597 DEBUG org.apache.http.wire.wire(): >> "[\r][\n]"
2012-01-16 22:02:10,597 DEBUG org.apache.http.headers.sendRequestHeader(): >> GET /hub/session/2fad55cf-670e-44f3-ab60-7d2f76f641e6/alert_text HTTP/1.1
2012-01-16 22:02:10,597 DEBUG org.apache.http.headers.sendRequestHeader(): >> Accept: application/json, image/png
2012-01-16 22:02:10,597 DEBUG org.apache.http.headers.sendRequestHeader(): >> Host: 127.0.0.1:7055
2012-01-16 22:02:10,597 DEBUG org.apache.http.headers.sendRequestHeader(): >> Connection: Keep-Alive
2012-01-16 22:02:10,612 DEBUG org.apache.http.wire.wire(): << "HTTP/1.1 200 OK[\r][\n]"
2012-01-16 22:02:10,612 DEBUG org.apache.http.wire.wire(): << "content-type: application/json; charset=UTF-8[\r][\n]"
2012-01-16 22:02:10,612 DEBUG org.apache.http.wire.wire(): << "connection: close[\r][\n]"
2012-01-16 22:02:10,612 DEBUG org.apache.http.wire.wire(): << "content-length: 236[\r][\n]"
2012-01-16 22:02:10,612 DEBUG org.apache.http.wire.wire(): << "server: httpd.js[\r][\n]"
2012-01-16 22:02:10,612 DEBUG org.apache.http.wire.wire(): << "date: Tue, 17 Jan 2012 03:02:10 GMT[\r][\n]"
2012-01-16 22:02:10,612 DEBUG org.apache.http.wire.wire(): << "[\r][\n]"
2012-01-16 22:02:10,612 DEBUG org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(): Receiving response: HTTP/1.1 200 OK
Or more detailed: No logging-request from com or org-packages with log-level < WARN will be enabled. So it wont be forwarded to your rootLogger.
Quote:
and
See: http://logging.apache.org/log4j/1.2/manual.html