logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Javier Gonzalez <jagon...@gmail.com>
Subject Re: Log4j logging to System.out?
Date Thu, 21 Jul 2005 21:00:36 GMT
So you don't touch the root logger anywhere?

(another thing that you could try is set your Logger's additivity to
false, that way it doesn't "relay" the events to its parent loggers)

On 7/21/05, Mike Wannamaker <Mike.Wannamaker@kingston.hummingbird.com> wrote:
> 
> Logger logger = Logger.getLogger(strLoggerName);
> setUpLoggerUsingGlobalAppender(logger);
> 
>         void setUpLoggerUsingGlobalAppender(Logger log)
>         {
>                 if(m_GlobalAppender == null)
>                 {
>                         try
>                         {
>                                 String strFileName = m_strLoggingDir +
> "/hcsnew.log";
>                                 File    logFile = new File(strFileName);
>                                 boolean bRoll = logFile.exists();
>                             logFile.getParentFile().mkdirs();
> 
>                                 if((System.getProperty("use.console.logger")
> != null) || ("CONSOLE".equals(System.getProperty("crusade.output"))))
>                                 {
>                                         System.out.println("CREATE CONSOLE
> LOGGER");
>                                         m_GlobalAppender = new
> ConsoleAppender(getLayout());
>                                 }
>                                 else
>                                 {
>                                         System.out.println("CREATE FILE
> LOGGER");
>                                         //get ready to log to files.
>                                         m_GlobalAppender = new
> BackupFileAppender(getLayout(), strFileName, true);
> 
> ((RollingFileAppender)m_GlobalAppender).setMaxBackupIndex(m_nMaxFiles);
> 
> ((RollingFileAppender)m_GlobalAppender).setMaximumFileSize(m_nMaxSize);
>                                         //if there is already a file with
> data in it the roll it over for a fresh one.
>                                         if (bRoll)
>                                         {
> 
> ((RollingFileAppender)m_GlobalAppender).rollOver();
>                                         }
> 
> ((RollingFileAppender)m_GlobalAppender).activateOptions();
>                                 }
> 
>                         }
>                         catch (Exception e)
>                         {
>                                 System.out.println("Error setting up logger:
> " + e.getMessage());
>                         }
>                 }
>                 log.setLevel(m_Level);
>                 if(m_GlobalAppender != null)
>                         log.addAppender(m_GlobalAppender);
>         }
> 
> -----Original Message-----
> From: Javier Gonzalez [mailto:jagonzal@gmail.com]
> Sent: July 21, 2005 12:05 PM
> To: Log4J Users List
> Subject: Re: Log4j logging to System.out?
> 
> Then show us your configuration code ;). Perhaps you are loading a
> basic configuration and then tweaking your Loggers? BasicConfiguration
> has an INFO-level ConsoleAppender attached to the RootLogger...
> 
> On 7/21/05, Mike Wannamaker <Mike.Wannamaker@kingston.hummingbird.com>
> wrote:
> > I don't have a log4j.properties file.  I configure the logger internally
> via
> > java code.  I install a RollingFileAppender only to each Logger that is
> > created and set it's level programmatically.  Could it be that the default
> > root logger logs certain levels to System.out and/or System.err?
> >
> > TIA
> > --ekiM
> >
> > -----Original Message-----
> > From: Jacob Kjome [mailto:hoju@visi.com]
> > Sent: July 21, 2005 12:00 AM
> > To: Log4J Users List
> > Subject: Re: Log4j logging to System.out?
> >
> > At 10:00 PM 7/20/2005 -0400, you wrote:
> >  >For some reason it looks like log.info(...) logs also to System.out.
> When
> > I
> >  >start my application in a console window, these statements log to the
> log
> >  >file and the console?  Any way to get it to stop?
> >
> > Can't begin to tell you until we see your config file.
> >
> > Jake
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
> 
> 
> --
> Javier Gonzalez Nicolini
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 


-- 
Javier Gonzalez Nicolini

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


Mime
View raw message