First, you should be using Logger, not Category. That goes for the config
as well: log4j.rootLogger instead of log4j.rootCategory. In any case,
that's not super important since either will work, but you should make a
practice of using Logger instead of Category for future compatibility.
So, on to your question...
You say you get duplicate logging? In your config, you have a single
appender defined which is attached to the root logger. Additivity does not
come into play here. It only comes into play when you define another
appender to a logger other than the root logger. In that case, if you want
to avoid additivity, then you set it on that logger. Of course, that would
mean that you would no longer get logging to the appender defined in the
root logger... unless you redefined that appender on the logger where you
set additivity=false. BTW, I'm not sure if the value for additivity is
case sensitive or not, but to be safe, I suggest using lower case "false"
rather than "FALSE".
I suspect that you are not providing all of your configuration or another
config file is being picked up than the one you think is being picked
up. Are you running in a standalone app or under an appserver? In any
case, I suggest using log4j.xml, since the auto-configuration that Log4j
provides picks up log4j.xml in preference to log4j.properties. So, if a
log4j.xml is sitting on the classpath (in the root package), it will get
used rather than your log4j.properties file.
Jake
At 09:50 AM 12/30/2005 -0800, you wrote:
> Hello log4j-user Team,
>
> I would be highly thankful to your guidance in this regard.I am changing
>log4j properties file to remove duplicate loggings for few of the java beans.
>
> This is how my properties files looks like -
>
> log4j.appender.OPC=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.OPC.DatePattern='.'yyyy-MM-dd
> log4j.appender.OPC.File=/log/bea/opc/opc_1.log
> log4j.appender.OPC.layout=org.apache.log4j.PatternLayout
> log4j.appender.OPC.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy}
>%-5p %c - %m%n
> # Set the root category default to DEBUG (default...).
> log4j.rootCategory=DEBUG, OPC
> log4j.additivity.com.onstar.pc.beans=FALSE
> log4j.additivity.com.onstar.pc.admin=FALSE
>
> Here I have set additivity property to false so that classes within beans
>and admin package are not logged twice. But I am still getting duplicate
>messages for classes within these package.
> In my java class, I am importing org.apache.log4j.Category and getting
>logger by
> org.apache.log4j.Category Logger = getLogger() and using in code as
> Logger.debug("writing the message");
>
> Please advise how can I remove duplicate logging.
>
> Thanks
> Pavi
>
>
>
>
>---------------------------------
>Yahoo! Photos
> Ring in the New Year with Photo Calendars. Add photos, events, holidays,
>whatever.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]