Hi,

I am a newbie to Log4cxx and
I am trying to use more than one logger, and searched through mailing list but solution given doesn’t seem to work.
Please look at my code and config file and reply me where I am doing   it wrong
 
  Code:
  -----
 
  PropertyConfigurator::configure(LOG4CXX_FILE(pbConfigFile));
  LoggerPtr rootLogger = Logger::getRootLogger(); logger = Logger::getLogger("sysmonLogger");
  LOG4CXX_INFO(logger, "********************* LOG OPEN  *********************\n");
 
  --  While I debug above code, this is the error message I got
 
  log4cxx: No appender could be found for logger (sysmonLogger).
  log4cxx: Please initialize the log4cxx system properly.
 
  Config:
  -------
  log4j.rootLogger=DEBUG
  log4j.*logger.*sysmonLogger=DEBUG, myappender
 
  log4j.additivity.sysmonLogger=false
  log4j.appender.myappender=org.apache.log4j.RollingFileAppender
  log4j.appender.myappender.File=../logs/sysmon.log
 
  log4j.appender.myappender.MaxFileSize=100KB
  log4j.appender.myappender.MaxBackupIndex=1
 
  log4j.appender.myappender.layout=org.apache.log4j.PatternLayout
 
  Thnx,
  Sandeep

----------------------------------
From mailing list:
----------------------------------
  Hi,
 
  after a long search on the internet, I have managed to do what I wanted:
  define multiple loggers.
  If it can help anybody, the solution to my problem was only to write
  this line in log4j.properties:
 
  log4j.*logger.*fraLogger = ERROR, ACSALogger2
 
  instead of this line:
 
  log4j.fraLogger = ERROR, ACSALogger2
 
  now, I can have more than one logger each writing to its own file.
  Regards
 
  Francois
 
 
  Francois MAROT wrote:
    Hi,
    and first of all, thanks for your quick responses.
    But I still can't get it to work ! :( In c++:
  
    PropertyConfigurator::configure("log4j.properties");
    LoggerPtr fraLogger = Logger::getLogger("fraLogger");
  
    In log4j.properties:
  
    log4j.rootLogger = DEBUG, ACSALogger
log4j.appender.ACSALogger =     org.apache.log4j.RollingFileAppender
    log4j.appender.ACSALogger.layout = org.apache.log4j.PatternLayout
    log4j.appender.ACSALogger.layout.ConversionPattern=%-4r [%t] %-5p %c
    %x - %m%n log4j.appender.ACSALogger.File = ACSALogger.log
    log4j.appender.ACSALogger.MaxFileSize=1KB
  
    log4j.fraLogger = ERROR, ACSALogger2
    log4j.additivity.fraLogger=false
    log4j.appender.ACSALogger2 = org.apache.log4j.RollingFileAppender
    log4j.appender.ACSALogger2.layout = org.apache.log4j.SimpleLayout
    log4j.appender.ACSALogger2.File = TMP.log
  
    The problem is that everything logged goes to ACSALogger.log and not
    to TMP.log.
    TMP.log receives data only if I tell rootlogger to use ACSALogger2
    too as a logger. The first line becomes :
    log4j.rootLogger = DEBUG, ACSALogger, ACSALogger2.
    The point is i'd like to have differents loggers for different parts
    of the software.
    Any more advice from you log4cxx users ?
  
    Regards
  
    Francois
  
  
    Francois MAROT wrote:
   
    
  ----------------------------------------------------------------------
  --
   
     Subject:
     Re: Newbie question
     From:
     Curt Arnold <carnold@apache.org
     Date:
     Mon, 27 Feb 2006 14:06:41 -0600
     To:
     Log4CXX User <log4cxx-user@logging.apache.org
   
     To:
     Log4CXX User <log4cxx-user@logging.apache.org
   
   
   
     On Feb 27, 2006, at 9:36 AM, Francois MAROT wrote:
   
      Hi all,
    
      i'm about to implement a logging system and have been
      experimenting with log4cxx recently. But i have some problems...
      The fact is I don't try to do anything very hard, only configuring
      properly my output to a desired file.
      I thought, as i stated in code i wanted to use logger
      "log4j.fraLogger", that my logging info would be written in the
      file named "TMP.log". But it is written in file
      "ACSA-log4cxx.log". I thought only rootlogger would write to this
      file... Am I missing something ?
    
   
     Looks like two things, one you are logging to "log4j.fraLogger" in
     the code, but are configuring "fraLogger" in the properties file.
     The "log4j." in the properties file just identifies the property as
     pertaining to log4j configuration and is discarded. If you change
     the argument in the getLogger call from "log4j.fraLogger" to
     "fraLogger", your log requests should go into both ACSA-log4cxx.log
     and TMP.log.
   
     As mentioned in the previous message, if you do not want messages
     to go to both files, you need to specify the "additivity" for the
     fraLogger to false so that it does not pass on the requests to
     appenders attached to the root. You would do that by adding the
     following line to your configuration file.
   
   
     log4j.additivity.fraLogger=false