Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

setting log4j properties at runtime

807600Jun 12 2007 — edited Jun 13 2007
Hi,

I am using log4j and want to take the logfile name as a command line argument.

Can anyone help as to how to set the properties which are done statically in log4j.propreties file....

I tried

logProperties.setProperty("log4j.appender.ROOT", "org.apache.log4j.RollingFileAppender");
logProperties.setProperty("log4j.appender.ROOT.File", fileName);
logProperties.setProperty("og4j.appender.ROOT.layout", "org.apache.log4j.PatternLayout");
logProperties.setProperty("log4j.appender.ROOT.layout.ConversionPattern", "%d{ISO8601} - <<<<< [%F][%M] %m >>>>>%n");

but that doesnot seem to work...as the log file itself is not created.

ANyone help is appreciated...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 11 2007
Added on Jun 12 2007
2 comments
276 views