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 ya...@avanzasolutions.com on 2008/05/22 14:39:16 UTC

how to pass a parameter to a customized appender?

Hi

 

I am using a web application which is deployed on tomcat server. I am using
log4j for logging purpose and use a customize Appender class
DailyMaxRollingFileAppender which extends DailyRollingFileAppender. I have
configured my log4j.properties file for DailyMaxRollingFileAppender. Inside
DailyMaxRollingFileAppender class, I am trying to access a property from a
property resource bundle. I have loaded property resource bundle in
ServletContextListener. When DailyMaxRollingFileAppender is loaded by log4j,
it throws NullPointerException while trying to access property resource
bundle. I am confued why my property resource bundle is not loaded? Does
log4j loads before the ServletContextListner is loaded? If yes , then what
is the remedy for it. I mean how come I pass my attribute/parameter to my
DailyMaxRollingFileAppender class.

 

 

 

Regards,

Yasir


Re: how to pass a parameter to a customized appender?

Posted by Jacob Kjome <ho...@visi.com>.
If you don't want the configuration in your log4j.xml or log4j.properties to be
loaded right away, then don't put it in the classpath.  Put it in, for instance,
WEB-INF.  Then, in your servlet context listener, set things up the way you want
and then perform manual configuration on the config file of your choice.

You might want to put a dummy minimal log4j.xml file in WEB-INF/classes that will
get picked the first time a class referencing Logger is classloaded (which will,
in turn load LogManager, which performs the auto-config in a static block) just to
make sure it doesn't pick up some arbitrary config file somewhere in the parent
classloader (assuming you are using Tomcat's child-first classloading behavior).

Jake

yasir.arsalan@avanzasolutions.com wrote:
> Hi
> 
>  
> 
> I am using a web application which is deployed on tomcat server. I am using
> log4j for logging purpose and use a customize Appender class
> DailyMaxRollingFileAppender which extends DailyRollingFileAppender. I have
> configured my log4j.properties file for DailyMaxRollingFileAppender. Inside
> DailyMaxRollingFileAppender class, I am trying to access a property from a
> property resource bundle. I have loaded property resource bundle in
> ServletContextListener. When DailyMaxRollingFileAppender is loaded by log4j,
> it throws NullPointerException while trying to access property resource
> bundle. I am confued why my property resource bundle is not loaded? Does
> log4j loads before the ServletContextListner is loaded? If yes , then what
> is the remedy for it. I mean how come I pass my attribute/parameter to my
> DailyMaxRollingFileAppender class.
> 
>  
> 
>  
> 
>  
> 
> Regards,
> 
> Yasir
> 
> 

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