0

My application takes an argument as input and all the other processes happen based on this argument

I would like to create log file with name based on the input parameter

Can anyone let me know how I can do this ?

I am using Log4J 1.2.17.

KK99
  • 1,971
  • 7
  • 31
  • 64

1 Answers1

1

Copied from the log4j manual Read Configuration section

public static void main(String[] args) {

 // BasicConfigurator replaced with PropertyConfigurator.
 PropertyConfigurator.configure(args[0]); //args[0] path to your log4 conf file   
}
Vasyl Keretsman
  • 2,688
  • 2
  • 18
  • 15
  • I am trying this, but I want to validate the input of course & also want to log the messages before.. Any other ideas? – KK99 Mar 14 '13 at 12:45
  • You need to configure the logger before logging. For other ideas to come you need to explain more in your original question. Why do you need it ? How are you going to use logging result? Do you really need such solution or it can be solved differently? – Vasyl Keretsman Mar 14 '13 at 13:04
  • I guess I can use your approach + writing to console for my use case. Thanks a lot – KK99 Mar 14 '13 at 13:22