Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing Log4J for my appliaction

 
Ramesh Etta
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

I had written a web application for some banking project in Struts. The problem is i have categorized the ActionForm classes into one package, Action classes in one package and so on. Now i have to log the logging information in to two different log files that contains, like in one log file all the creation of accounts information must be logged and in other log file Viewing of balance info, transfer and so on log information and may be all the error information in to one more log file. I want to write the configuration file in an xml file. can any one tell me how this can be possible. ie how we are going to categorize logging information into different log files base on the fucntionality of our application. I feel happy if any one can come with code.

I am using Struts and Log4JLogger.

Thanks in advance.
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a naming strategy other than the fully qualified class names to group your logging by whatever you want.

From short introduction to log4j

Log4j makes it easy to name loggers by software component. This can be accomplished by statically instantiating a logger in each class, with the logger name equal to the fully qualified name of the class. This is a useful and straightforward method of defining loggers. As the log output bears the name of the generating logger, this naming strategy makes it easy to identify the origin of a log message. However, this is only one possible, albeit common, strategy for naming loggers. Log4j does not restrict the possible set of loggers. The developer is free to name the loggers as desired.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic