Cristian,

I don't have time to work out an entire example, but you should look into
doing the following in your configuration file:

1) Create an appender for the security, database, and application.
2) Attach the application appender to the root logger.
3) Attach the security appender to a logger with the package name of the
security package; set the logger's additivity property to false.
4) Attach the database appender to a logger with the package name of the
database package; set the logger's additivity property to false.
5) You can set the level property of the package loggers or set the
threshold of the appenders to adjust the level of the messages appended.

Because of the way log4j handles logging, messages are handled by a
"hierarchy" of loggers.  So, let's say that your security package is named
"com.mycompany.security", which has the secutiry appender attached to it in
the configuration file.  If your code creates instances of loggers with
names like "com.mycompany.security.Authenticator" and
"com.mycompany.security.SecutiryBreach", due the hierarchical nature, these
loggers' messages will be appended to the appenders attached to the
"com.mycompany.security" logger defined in the configuration file.

hope it helps,
-Mark

> -----Original Message-----
> From: Georgescu, Cristian [IT] 
> [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 03, 2002 11:07 AM
> To: 'Log4J Users List'
> Subject: Log4J and multiple logging files?
> 
> 
> I try to have multiple log files using log4j and it doesn't 
> seem to work.
> 
> I want to be able to use separate property files when I 
> initialize each of
> the categories (loggers). 
> Each category is for a separate Java package. The top-level 
> application uses
> all the packages and would expect a log file per package.
> 
> Example: An application that uses a database package and a 
> security package.
> Each package should have it's own log file, plus a log file for the
> appliation itself. The database package would log only 
> database errors, the
> security package would log only security errors, etc. In this 
> case there
> would be a database log file, a security log file and an 
> application log
> file.
> 
> There seems to be no way to configure log4j for this.
> 
> Anyboby could help or suggest a work around for this?
> Thanks,
> 
> Cristian Georgescu
> Salomon Smith Barney
> Private Client Infrastructure
> Phone: 212-723-2055
> [EMAIL PROTECTED]
> 
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to