This post is more than 5 years old
18 Posts
0
3145
June 7th, 2010 15:00
Atmos Storage Java API log4j
The Atmos Java API implements logging via log4j. I really don't need logging. Does anyone know how to properly set up log4j, or to simply make it be quiet? I could tear it out of the API, but that seems a bit drastic. I checked the internet, but the log4j examples are exceptionally underwhelming.
My output:
C:\Data\atmoscli\bin>java -cp .;..\lib\* atmos ls /boot/
/boot/
log4j:WARN No appenders could be found for logger (com.emc.esu.api.rest.EsuRestApi).
log4j:WARN Please initialize the log4j system properly.
F /boot/boot.ini 4980cdb2a110105a04bf484d95d6a004c08036d5d40f
C:\Data\atmoscli\bin>
Jason Thornbrugh
Principal Solutions Engineer
GSC Demo Cloud
0 events found
No Events found!


aashishpatil
2 Intern
•
212 Posts
0
June 7th, 2010 15:00
Hmm, ok -
See if something like this works -
OR
Check Logger, Level objects in the log4j JavaDocs.
http://logging.apache.org/log4j/1.2/apidocs
aashishpatil
2 Intern
•
212 Posts
0
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
thornj1
18 Posts
0
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
thornj1
18 Posts
0
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);
...