tags:

views:

41

answers:

1

Currently I am getting log in either in file or either on console but i want log on both so how can i configure log4j.prop for it??

+2  A: 

you need to have setting like this:

log4j.rootLogger=DEBUG, console, R

Then provide settings for console appender , Rolling file appender.

ex:

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %5p %c (%F:%L) – %m%n
....

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=./logs/app.log
log4j.appender.R.MaxFileSize=5MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %5p [%t] (%C:%L) - %m%n
.....
daedlus