logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: File Appender help
Date Tue, 07 Dec 2004 05:17:38 GMT
At 03:29 PM 12/6/2004 +0100, you wrote:
 >Hi all,
 >I'm new on log4j project, I need to  configure log4j.properites to create
 >more FileAppeder.
 >For examples :
 >MyClass1 should have .\log\file1.log
 >MyServlet1 should have \log\servlet\Servlet1.log
 >JSP should have \log\JSP\Servlet1.log

Why do you want to create a separate log file for each class?  Or do you 
mean that all basic classes log to one file, all servlets log to another 
file, and all JSP's log to another file?  That could be achieved if your 
logger naming scheme allows you to distinguish between these various contexts.

 >and so on..
 >I have read log4j documentation but i only found this example:
 ># Set root category priority to DEBUG and using Appender FileLogger
 >log4j.rootCategory=DEBUG, FileLogger
 >A file name sould depends on class and some more parameter
 >Is there a way to set the file name not in .properties file?

Hmm... not really the way you seem to want to do it here.  You can make the 
file name and location dynamic by referencing a system property and making 
sure that this property gets set before initialization.  However, you seem 
to be talking about using one appender but dynamically having it write to 
different files depending on the logger being used.  This is a bit 
backward, at least in the Log4j world (and all other logging frameworks I 
am aware of).  I would create an appender for each file you want created 
and then configure your loggers with the appropriate appender.

On the chance that you simply mean not hard coding the file name in the 
properties, file, here's how you reference a system property...




To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message