dcsimg
Multiple logging using same property file in Log4j
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anil_Kumar
Posted On:   Sunday, December 21, 2003 08:21 PM

hi I am developing an application which requires to work as web services and also in standalone mode. In web services the logging is done fully in certain log file In stand alone more, i do require to log both in console and files programatically based on the functionality. I know that both console and file appenders can be used in the log4j.rootLogger variable in the log4j.propeties. But this seems to log same output in both console and file. But i do want to control it programatically depending on the situation. Can i use the property file to control this requirement?/ Can i get control on the configured parameters of property file in the code. Pls help me with example links Th   More>>

hi
I am developing an application which requires to work as web services and also in standalone mode.
In web services the logging is done fully in certain log file
In stand alone more, i do require to log both in console and files programatically based on the functionality.

I know that both console and file appenders can be used in the log4j.rootLogger variable in the log4j.propeties. But this seems to log same output in both console and file.
But i do want to control it programatically depending on the situation.

Can i use the property file to control this requirement?/
Can i get control on the configured parameters of property file in the code.
Pls help me with example links

Thanks in advance

regards
Anil

   <<Less

Re: Multiple logging using same property file in Log4j

Posted By:   ravi_sambandam  
Posted On:   Monday, February 16, 2004 10:49 PM

Hi,


You can write a appender class which will log both in console as well in a output file and configure this as the appender class in the property file

Define a attribute in the property file with a boolean value.

In the appender class written by you check for the boolean attributes value.Based on it write it both console and file or only to a file.

For that attribute u need to define get/set method in the appender class

ravi sambandam
About | Sitemap | Contact