You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Hitesh Raghav <hi...@lycos.com> on 2006/02/23 07:48:37 UTC

Component specific logging

Hi All,

In my application 3-4 third party components are being used. For logging configuration, all the components are refering to "log4j.properties". It's placed in "properties" folder of application server. 
Therefore, all the coponents are logging into the same log file.

I've to generate the component specific log file.

Could you please guide me regarding the same.

Note: I've no access on any third party component's code.


Thanks and Regards,

HITESH RAGHAV
Bangalore - 560 047, India.
Tel: +91-80-2841 0680  Extn:289 (W)
Cell: +91-924 310 2033
Fax: +91-80-2841 0690 (W)
eMail: hitesh_raghav@lycos.com
       Hitesh.Raghav@misys.com (W)



-- 
_______________________________________________

Search for businesses by name, location, or phone number.  -Lycos Yellow Pages

http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10


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


Re: Component specific logging

Posted by Javier Gonzalez <ja...@gmail.com>.
I think that you need to identify the naming scheme for the loggers of each
3rd party component (by doing a test run at debug level with a layout
configuration that prints the whole logger name), and then configure log4j
to send each of those logger hierachies to distinct files.

For example, suppose you have four 3rd party components, and their logger
naming schemas are like this:

component 1: com.somecompany.component1.*
component 2: com.anothercompany.component2.*
component 3: com.yetanothercompany.component3.*
component 4: org.someorg.component4.*

I'd proceed like this:

1.- configure root logger as desired

2.- turn off additivity on each component, like this:

log4j.additivity.com.somecompany.component1=false

3.- Configure each component logging hierachy with desired level and
attaching the proper appender (as defined in the next point):

log4j.logger.com.somecompany.component1=INFO,Component1Appender

4.- Configure a file appender to each component logging hierachy, for
example:

log4j.appender.Component1Appender=org.apache.log4j.RollingFileAppender
log4j.appender.Component1Appender.Append=true
log4j.appender.Component1Appender.MaxBackupIndex=3
log4j.appender.Component1Appender.File=component1.log
log4j.appender.Component1Appender.layout=org.apache.log4j.PatternLayout
log4j.appender.Component1Appender.layout.ConversionPattern=%d{ISO8601}%c{1}>
%m%n

Turning off additivity will ensure that you don't get a component logs mixup
at the root logger level.

Cheers,

Javier.

On 2/23/06, Hitesh Raghav <hi...@lycos.com> wrote:
>
> Hi All,
>
> In my application 3-4 third party components are being used. For logging
> configuration, all the components are refering to "log4j.properties". It's
> placed in "properties" folder of application server.
> Therefore, all the coponents are logging into the same log file.
>
> I've to generate the component specific log file.
>
> Could you please guide me regarding the same.
>
> Note: I've no access on any third party component's code.
>
>
> Thanks and Regards,
>
> HITESH RAGHAV
> Bangalore - 560 047, India.
> Tel: +91-80-2841 0680  Extn:289 (W)
> Cell: +91-924 310 2033
> Fax: +91-80-2841 0690 (W)
> eMail: hitesh_raghav@lycos.com
>        Hitesh.Raghav@misys.com (W)
>
>
>
> --
> _______________________________________________
>
> Search for businesses by name, location, or phone number.  -Lycos Yellow
> Pages
>
>
> http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


--
Javier González Nicolini