2 Intern

 • 

212 Posts

June 7th, 2010 15:00

Hmm, ok -

See if something like this works -

Logger atmosLogger = Logger.getLogger("com.emc.esu");

atmosLogger.setLevel(Level.OFF); //completely turn of logging. Never tried this option but read it in the JavaDocs.

OR

atmosLogger.setLevel(Level.FATAL); //turn off logging for anything less than FATAL

Check Logger, Level objects in the log4j JavaDocs.

http://logging.apache.org/log4j/1.2/apidocs

2 Intern

 • 

212 Posts

June 7th, 2010 15:00

Hi Jason,

Actually, based on the messages you are seeing, log4j is probably not working because it could not load the configuration. You could safely ignore the WARN messages below unless you want the logging to work.

Aashish

18 Posts

June 7th, 2010 15:00

Yes, they can be safely ignored, but I want them to be supressed since I'm going to wrap this inside of an existing script and parse the text output of the Java command.  FYI, the server that this will be run on is not a web server.

Ideally, I'd like to configure log4j programatically (not using an external configuration file).  I just want the logging to go to the "bit bucket" with no warnings to the console.

Jason Thornbrugh
Principal Solutions Engineer
GSC Demo Cloud

18 Posts

June 7th, 2010 16:00

My HTML was munged after posting.  So much for WYSIWYG!  Reposted as plaintext:


Thanks! Your suggestion worked perfectly. I also found a simple log4j sample online in case I want to enable logging later.  In case anyone else has this question, here is the code that worked for me:


Disable log4j for com.emc.esu
-----------------------------

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
...
Logger atmosLogger=Logger.getLogger("com.emc.esu");
atmosLogger.setLevel(Level.OFF); //completely turn of logging.
...

Set log4j to log to the console for com.emc.esu
-----------------------------------------------

import org.apache.log4j.Logger;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.SimpleLayout;
...
//
http://www.mail-archive.com/log4j-user@logging.apache.org/msg05637.html
Logger atmosLogger=Logger.getLogger("com.emc.esu");
ConsoleAppender a0 = new ConsoleAppender(new SimpleLayout());
atmosLogger.addAppender(a0);
Logger rootLogger = Logger.getRootLogger();
a0.activateOptions();
rootLogger.addAppender(a0);
...


No Events found!

Top