File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes Writing Log4J for my appliaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Writing Log4J for my appliaction" Watch "Writing Log4J for my appliaction" New topic

Writing Log4J for my appliaction

Ramesh Etta
Ranch Hand

Joined: Sep 18, 2007
Posts: 47
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
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
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.
I agree. Here's the link:
subject: Writing Log4J for my appliaction
jQuery in Action, 3rd edition