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 Fri, 22 Jul 2005 18:13:31 GMT
yes, with Logger.getRootLogger(). That will get you the root Logger of
your Logger hierachy to tinker with at your whim ;)

On 7/22/05, Mike Wannamaker <Mike.Wannamaker@kingston.hummingbird.com> wrote:
> I set my root logger additivity to false and it works.
> 
> However, can I get the root logger and add/change appenders for it
> programmatically?  Some logging from other 3rd party loggers are still
> showing up but I could redirect their output to my appender by adding it to
> the root logger.
> 
> TIA
> --ekiM
> 
> -----Original Message-----
> From: Javier Gonzalez [mailto:jagonzal@gmail.com]
> Sent: July 22, 2005 9:29 AM
> To: Log4J Users List
> Subject: Re: Log4j logging to System.out?
> 
> Mmm, as I understand it, the additiviy goes up the Logger hierachy, not
> down.
> What (seems to me) you should do is set the additivity if your
> application Loggers to false, so that the root Logger doesn't get
> application logs.
> 
> If you have a Logger foo created with Logger.getLogger(foo) and log a
> info message like foo.info("This is an info level log"), foo will log
> this message, print it to all attached appenders, and pass the message
> along to the parent logger. So you will also get 'This is an info
> level log' in your root Logger. If you disable additivity in logger
> foo, the message will only be logged to the appenders explicitly
> attached to the foo logger, and not in the appenders that are attached
> to the root Logger.
> 
> (if I'm wrong somebody please correct me :)
> 
> On 7/22/05, Mike Wannamaker <Mike.Wannamaker@kingston.hummingbird.com>
> wrote:
> > No I don't touch it.  Can I set additivity to false for my root logger so
> > that it doesn't relay events yet all my child loggers will?
> >
> > --ekiM
> >
> > -----Original Message-----
> > From: Javier Gonzalez [mailto:jagonzal@gmail.com]
> > Sent: July 21, 2005 5:01 PM
> > To: Log4J Users List
> > Subject: Re: Log4j logging to System.out?
> >
> > 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
> >
> > ---------------------------------------------------------------------
> > 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