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 Telematics News <tl...@yahoo.com> on 2005/12/30 18:50:57 UTC

Duplicate log4j messages appearing in logs

    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.

Re: Duplicate log4j messages appearing in logs

Posted by Jacob Kjome <ho...@visi.com>.
At 02:23 PM 12/30/2005 -0800, you wrote:
 >    Hello,
 >
 >  I will use Logger in the future new applications.
 >
 >  This application runs in weblogic8.1 server.I am using log4j-1.2.8.jar.
 >Also I have checked my classpath there is no log4j.xml file.
 >

I believe the syntax is correct.  However, you still use "FALSE" rather 
than "false" as I suggested in my last response.  Please try "false".  If 
Log4j makes no attempt to do a toLowerCase() or anything (haven't checked 
the source for this), then "FALSE" wouldn't match the Boolean object 
requirements.  It requires lower case.

Jake

 >  Here is the complete log4j.properties file.
 >
 >  #The OPC log is the dumping ground for non-specific messages
 >  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
 >  ##CR-13893 remove duplicate logging
 >  ########### End Base Log Settings ##############
 >  ########### Begin Provisoning Log Settings ##############
 >  log4j.appender.PROVISIONINIG=org.apache.log4j.DailyRollingFileAppender
 >  log4j.appender.PROVISIONINIG.DatePattern='.'yyyy-MM-dd
 >  log4j.appender.PROVISIONINIG.File=/log/bea/opc/provisioning_1.log
 >  log4j.appender.PROVISIONINIG.layout=org.apache.log4j.PatternLayout
 >  log4j.appender.PROVISIONINIG.layout.ConversionPattern=%d{EEE MMM dd
 >HH:mm:ss z yyyy} %-5p %c - %m%n
 >  log4j.additivity.com.onstar.pc.beans.ProvisioningBean=FALSE
 >  log4j.category.com.onstar.pc.beans.ProvisioningBean=DEBUG,PROVISIONINIG
 >  log4j.category.com.onstar.pc.servlet.ActivateResponse=DEBUG,PROVISIONINIG
 >  ########### End Provisoning Log Settings ##############
 >  ########### Begin VRM Log Settings ##############
 >  log4j.appender.VRM=org.apache.log4j.DailyRollingFileAppender
 >  log4j.appender.VRM.DatePattern='.'yyyy-MM-dd
 >  log4j.appender.VRM.File=/log/bea/opc/vrm_1.log
 >  log4j.appender.VRM.layout=org.apache.log4j.PatternLayout
 >  log4j.appender.VRM.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy}
 >%-5p %c - %m%n
 >  log4j.additivity.com.onstar.pc.vrm=FALSE
 >  log4j.category.com.onstar.pc.vrm=DEBUG,VRM
 >  ########### End VRM Log Settings ##############
 >  ########### Begin OSS Log Settings ##############
 >  # OSS Business Logic Components (EJBs)
 >  log4j.appender.OSS=org.apache.log4j.DailyRollingFileAppender
 >  log4j.appender.OSS.DatePattern='.'yyyy-MM-dd
 >  log4j.appender.OSS.File=/log/bea/opc/oss_1.log
 >  log4j.appender.OSS.layout=org.apache.log4j.PatternLayout
 >  log4j.appender.OSS.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy}
 >%-5p %c %l %x- %m%n
 >  # DHS Web and Presentation Components (Struts Actions, Forms, Servlets..)
 >  log4j.appender.OSS_WEB=org.apache.log4j.DailyRollingFileAppender
 >  log4j.appender.OSS_WEB.DatePattern='.'yyyy-MM-dd
 >  log4j.appender.OSS_WEB.File=/log/bea/opc/oss_web_1.log
 >  log4j.appender.OSS_WEB.layout=org.apache.log4j.PatternLayout
 >  log4j.appender.OSS_WEB.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z
 >yyyy} %-5p %c %l %x- %m%n
 >  log4j.additivity.com.onstar.oss=FALSE
 >  log4j.category.com.onstar.oss=DEBUG,OSS
 >  log4j.additivity.com.onstar.oss.web=FALSE
 >  log4j.category.com.onstar.oss.web=DEBUG,OSS_WEB
 >  ########### End OSS Log Settings ##############
 >
 >  ########### Begin DHS Log Settings ##############
 >  # DHS Business Logic Components (EJBs)
 >  log4j.appender.DHS=org.apache.log4j.DailyRollingFileAppender
 >  log4j.appender.DHS.DatePattern='.'yyyy-MM-dd
 >  log4j.appender.DHS.File=/log/bea/opc/dhs_1.log
 >  log4j.appender.DHS.layout=org.apache.log4j.PatternLayout
 >  log4j.appender.DHS.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy}
 >%-5p %c %l %x- %m%n
 >  # DHS Web and Presentation Components (Struts Actions, Forms, Servlets..)
 >  log4j.appender.DHS_WEB=org.apache.log4j.DailyRollingFileAppender
 >  log4j.appender.DHS_WEB.DatePattern='.'yyyy-MM-dd
 >  log4j.appender.DHS_WEB.File=/log/bea/opc/dhs_web_1.log
 >  log4j.appender.DHS_WEB.layout=org.apache.log4j.PatternLayout
 >  log4j.appender.DHS_WEB.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z
 >yyyy} %-5p %c %l %x- %m%n
 >  log4j.additivity.com.onstar.dhs=FALSE
 >  log4j.category.com.onstar.dhs=DEBUG,DHS
 >  log4j.additivity.com.onstar.dhs.web=FALSE
 >  log4j.category.com.onstar.dhs.web=DEBUG,DHS_WEB
 >  ########### End DHS Log Settings ##############
 >  ########### Begin Security Log Settings ##############
 >  log4j.appender.SECURITY=org.apache.log4j.DailyRollingFileAppender
 >  log4j.appender.SECURITY.DatePattern='.'yyyy-MM-dd
 >  log4j.appender.SECURITY.File=/log/bea/opc/security_1.log
 >  log4j.appender.SECURITY.layout=org.apache.log4j.PatternLayout
 >  log4j.appender.SECURITY.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z
 >yyyy} %-5p %c %l %x- %m%n
 >  log4j.additivity.com.onstar.common.security=FALSE
 >  log4j.category.com.onstar.common.security=DEBUG,SECURITY
 >  ########### End Security Log Settings ##############
 >  ########### Begin ACDM Log Settings ##############
 >  log4j.appender.ACDM=org.apache.log4j.DailyRollingFileAppender
 >  log4j.appender.ACDM.DatePattern='.'yyyy-MM-dd
 >  log4j.appender.ACDM.File=/log/bea/opc/acdm_1.log
 >  log4j.appender.ACDM.layout=org.apache.log4j.PatternLayout
 >  log4j.appender.ACDM.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z
 >yyyy} %-5p %c %l %x- %m%n
 >  log4j.additivity.com.onstar.acdm=FALSE
 >  log4j.category.com.onstar.acdm=DEBUG,ACDM
 >  ########### End ACDM Log Settings ##############
 >  ########### Begin VDM Log Settings ##############
 >  log4j.appender.VDM=org.apache.log4j.DailyRollingFileAppender
 >  log4j.appender.VDM.DatePattern='.'yyyy-MM-dd
 >  log4j.appender.VDM.File=/log/bea/opc/vdm_1.log
 >  log4j.appender.VDM.layout=org.apache.log4j.PatternLayout
 >  log4j.appender.VDM.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy}
 >%-5p %c %l %x- %m%n
 >  log4j.additivity.com.onstar.vdm=FALSE
 >  log4j.category.com.onstar.vdm=DEBUG,VDM
 >  ########### End VDM Log Settings ################
 >  ########### Begin VDU Log Settings ##############
 >  log4j.appender.VDU=org.apache.log4j.DailyRollingFileAppender
 >  log4j.appender.VDU.DatePattern='.'yyyy-MM-dd
 >  log4j.appender.VDU.File=/log/bea/opc/vdu_1.log
 >  log4j.appender.VDU.layout=org.apache.log4j.PatternLayout
 >  log4j.appender.VDU.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy}
 >%-5p %c %l %x- %m%n
 >  log4j.additivity.com.onstar.vdu=FALSE
 >  log4j.category.com.onstar.vdu=DEBUG,VDU
 >  ########### End VDu Log Settings ################
 >  ########### Begin Axis Log Settings ##############
 >  log4j.appender.AXIS=org.apache.log4j.DailyRollingFileAppender
 >  log4j.appender.AXIS.DatePattern='.'yyyy-MM-dd
 >  log4j.appender.AXIS.File=/log/bea/opc/axis_1.log
 >  log4j.appender.AXIS.layout=org.apache.log4j.PatternLayout
 >  log4j.appender.AXIS.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z
 >yyyy} %-5p %c %l %x- %m%n
 >  log4j.additivity.org.apache.axis=FALSE
 >  log4j.category.org.apache.axis=INFO,AXIS
 >  ########### End Axis Log Settings ################
 >   Any suggestions!!
 >
 >  Thanks
 >  Pavi
 >
 >  Jacob Kjome <ho...@visi.com> wrote:
 >
 >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: log4j-user-unsubscribe@logging.apache.org
 >For additional commands, e-mail: log4j-user-help@logging.apache.org
 >
 >
 >
 >
 >
 >
 >
 >---------------------------------
 > Yahoo! DSL Something to write home about. Just $16.99/mo. or less


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


Re: Duplicate log4j messages appearing in logs

Posted by Telematics News <tl...@yahoo.com>.
    Hello,
   
  I will use Logger in the future new applications. 
   
  This application runs in weblogic8.1 server.I am using log4j-1.2.8.jar. Also I have checked my classpath there is no log4j.xml file.
   
  Here is the complete log4j.properties file.
   
  #The OPC log is the dumping ground for non-specific messages
  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
  ##CR-13893 remove duplicate logging
  ########### End Base Log Settings ##############
  ########### Begin Provisoning Log Settings ##############
  log4j.appender.PROVISIONINIG=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.PROVISIONINIG.DatePattern='.'yyyy-MM-dd
  log4j.appender.PROVISIONINIG.File=/log/bea/opc/provisioning_1.log
  log4j.appender.PROVISIONINIG.layout=org.apache.log4j.PatternLayout
  log4j.appender.PROVISIONINIG.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy} %-5p %c - %m%n
  log4j.additivity.com.onstar.pc.beans.ProvisioningBean=FALSE
  log4j.category.com.onstar.pc.beans.ProvisioningBean=DEBUG,PROVISIONINIG
  log4j.category.com.onstar.pc.servlet.ActivateResponse=DEBUG,PROVISIONINIG
  ########### End Provisoning Log Settings ##############
  ########### Begin VRM Log Settings ##############
  log4j.appender.VRM=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.VRM.DatePattern='.'yyyy-MM-dd
  log4j.appender.VRM.File=/log/bea/opc/vrm_1.log
  log4j.appender.VRM.layout=org.apache.log4j.PatternLayout
  log4j.appender.VRM.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy} %-5p %c - %m%n
  log4j.additivity.com.onstar.pc.vrm=FALSE
  log4j.category.com.onstar.pc.vrm=DEBUG,VRM
  ########### End VRM Log Settings ##############
  ########### Begin OSS Log Settings ##############
  # OSS Business Logic Components (EJBs)
  log4j.appender.OSS=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.OSS.DatePattern='.'yyyy-MM-dd
  log4j.appender.OSS.File=/log/bea/opc/oss_1.log
  log4j.appender.OSS.layout=org.apache.log4j.PatternLayout
  log4j.appender.OSS.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy} %-5p %c %l %x- %m%n
  # DHS Web and Presentation Components (Struts Actions, Forms, Servlets..)
  log4j.appender.OSS_WEB=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.OSS_WEB.DatePattern='.'yyyy-MM-dd
  log4j.appender.OSS_WEB.File=/log/bea/opc/oss_web_1.log
  log4j.appender.OSS_WEB.layout=org.apache.log4j.PatternLayout
  log4j.appender.OSS_WEB.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy} %-5p %c %l %x- %m%n
  log4j.additivity.com.onstar.oss=FALSE
  log4j.category.com.onstar.oss=DEBUG,OSS
  log4j.additivity.com.onstar.oss.web=FALSE
  log4j.category.com.onstar.oss.web=DEBUG,OSS_WEB
  ########### End OSS Log Settings ##############
   
  ########### Begin DHS Log Settings ##############
  # DHS Business Logic Components (EJBs)
  log4j.appender.DHS=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.DHS.DatePattern='.'yyyy-MM-dd
  log4j.appender.DHS.File=/log/bea/opc/dhs_1.log
  log4j.appender.DHS.layout=org.apache.log4j.PatternLayout
  log4j.appender.DHS.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy} %-5p %c %l %x- %m%n
  # DHS Web and Presentation Components (Struts Actions, Forms, Servlets..)
  log4j.appender.DHS_WEB=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.DHS_WEB.DatePattern='.'yyyy-MM-dd
  log4j.appender.DHS_WEB.File=/log/bea/opc/dhs_web_1.log
  log4j.appender.DHS_WEB.layout=org.apache.log4j.PatternLayout
  log4j.appender.DHS_WEB.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy} %-5p %c %l %x- %m%n
  log4j.additivity.com.onstar.dhs=FALSE
  log4j.category.com.onstar.dhs=DEBUG,DHS
  log4j.additivity.com.onstar.dhs.web=FALSE
  log4j.category.com.onstar.dhs.web=DEBUG,DHS_WEB
  ########### End DHS Log Settings ##############
  ########### Begin Security Log Settings ##############
  log4j.appender.SECURITY=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.SECURITY.DatePattern='.'yyyy-MM-dd
  log4j.appender.SECURITY.File=/log/bea/opc/security_1.log
  log4j.appender.SECURITY.layout=org.apache.log4j.PatternLayout
  log4j.appender.SECURITY.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy} %-5p %c %l %x- %m%n
  log4j.additivity.com.onstar.common.security=FALSE
  log4j.category.com.onstar.common.security=DEBUG,SECURITY
  ########### End Security Log Settings ##############
  ########### Begin ACDM Log Settings ##############
  log4j.appender.ACDM=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.ACDM.DatePattern='.'yyyy-MM-dd
  log4j.appender.ACDM.File=/log/bea/opc/acdm_1.log
  log4j.appender.ACDM.layout=org.apache.log4j.PatternLayout
  log4j.appender.ACDM.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy} %-5p %c %l %x- %m%n
  log4j.additivity.com.onstar.acdm=FALSE
  log4j.category.com.onstar.acdm=DEBUG,ACDM
  ########### End ACDM Log Settings ##############
  ########### Begin VDM Log Settings ##############
  log4j.appender.VDM=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.VDM.DatePattern='.'yyyy-MM-dd
  log4j.appender.VDM.File=/log/bea/opc/vdm_1.log
  log4j.appender.VDM.layout=org.apache.log4j.PatternLayout
  log4j.appender.VDM.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy} %-5p %c %l %x- %m%n
  log4j.additivity.com.onstar.vdm=FALSE
  log4j.category.com.onstar.vdm=DEBUG,VDM
  ########### End VDM Log Settings ################
  ########### Begin VDU Log Settings ##############
  log4j.appender.VDU=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.VDU.DatePattern='.'yyyy-MM-dd
  log4j.appender.VDU.File=/log/bea/opc/vdu_1.log
  log4j.appender.VDU.layout=org.apache.log4j.PatternLayout
  log4j.appender.VDU.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy} %-5p %c %l %x- %m%n
  log4j.additivity.com.onstar.vdu=FALSE
  log4j.category.com.onstar.vdu=DEBUG,VDU
  ########### End VDu Log Settings ################
  ########### Begin Axis Log Settings ##############
  log4j.appender.AXIS=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.AXIS.DatePattern='.'yyyy-MM-dd
  log4j.appender.AXIS.File=/log/bea/opc/axis_1.log
  log4j.appender.AXIS.layout=org.apache.log4j.PatternLayout
  log4j.appender.AXIS.layout.ConversionPattern=%d{EEE MMM dd HH:mm:ss z yyyy} %-5p %c %l %x- %m%n
  log4j.additivity.org.apache.axis=FALSE
  log4j.category.org.apache.axis=INFO,AXIS
  ########### End Axis Log Settings ################
   Any suggestions!!
   
  Thanks
  Pavi
   
  Jacob Kjome <ho...@visi.com> wrote:
  
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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

  




		
---------------------------------
 Yahoo! DSL Something to write home about. Just $16.99/mo. or less

Re: Duplicate log4j messages appearing in logs

Posted by Jacob Kjome <ho...@visi.com>.
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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org