Modifying output generated by java.util.logging.Logger

Hi
I am using SimpleFormatter class to generate log file. the output looks like following
Mar 13, 2009 3:24:42 AM HostHandler readParameters
FINE: Starting to read input parameters
I want it to print only "Starting to read input parameters". I called logger.fine("Starting to read input parameters");
How can we do that?

I was able to fix it. I use my own formatter. here is the code
public class MyLogFormatter extends Formatter {
private static final String lineSep = System.getProperty("line.separator");
@Override
public String format(LogRecord record) {
return record.getMessage().concat(lineSep);
Reference : http://www.javalobby.org/java/forums/t18515.html

Similar Messages

  • Preventing java.util.logging.Logger from writing to STD ERR.

    Hi!
    I'm currently writing a program which uses the java.util.logging package for logging. For some reason it writes ALL logging to std err (as well as to the designated (file) handlers). From what I gather, this is probably done via a ConsoleHandler, but I certainly haven't added any ConsoleHandler. I've also tried printing all registered handlers, which only returns one FileHandler (i.e. the one I added :)).
    The following is a simplification of the code I use:
    private static Logger log = Logger.getLogger("my.package");
        static{
             String logfile = "log.txt";          
              try{
                   FileHandler fh = new FileHandler(logfile);
                   fh.setFormatter(new Formatter() {
                        public String format( LogRecord record){
                             return record.getLevel()+ " " +new Date(record.getMillis()).toString() + ": " +record.getMessage()+ "\n";
                   System.out.println(log.getHandlers().length);
                   log.addHandler(fh);
                   log.setLevel(Level.ALL);
              }catch(IOException e){
                   Frontend.getInstance().displayWarning("Unable to write to log file at "+logfile);
        }Any help on this would be greatly appreciated!

    The speed and on-the-spotness of that reply totally blew me away. Thanks alot, buddy :).

  • Getting no output from java.util.logging.FileHandler

    I am new to Java as is the company I work for, but we have just landed a contract that specifies J2EE as the platform, so here we are. :-) Please bear with me.
    I have been charged with determining our logging architecture and it looks like what is available in java.util.logging will do well (though we may use log4j). However, at this point I am just trying to get anything to work and not having much luck.
    We are using JSF on the front end and I have created a very simple JSF page to test logging. The relevant code is below and I hope will be self explanatory: This code is not meant to be efficient or anything. It is just a proof of concept.
        public String button1_action() {
            // User event code here...
            try {
                Logger l = java.util.logging.Logger.getLogger(Page1.class.getName());
                l.entering(Page1.class.getName(), "button1_action");
                l.info(this.textField1.getValue().toString());
                l.exiting(Page1.class.getName(), "button1_action");
                java.util.logging.Handler h = l.getHandlers()[0];
                h.flush();
            catch(Exception ex) {
                //I have tested this and we aren?t catching any errors.
                System.err.println(ex);
            return "";
        }My logger.properties files looks like this:
    handlers= java.util.logging.FileHandler
    .level= FINEST
    java.util.logging.FileHandler.pattern = c:/sun/logs/test-%u.log
    java.util.logging.FileHandler.limit = 50000
    java.util.logging.FileHandler.count = 1
    java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatterI have developed and tested this in Sun Studio Creator 2004Q2 What is happening is that I am getting three log files in c:/sun/logs
    test-0.log, test-1.log and test-2.log. The first two contain output from various sun components. (sun.rmi.transport for example). The third log remains empty. (zero length)
    I have also deployed the test app to a tomcat 5.0.28 server and get similar results. The only difference is I get only one two log files and the second one remains empty.
    Any assistance or suggestions as to what direction I should be taking would be appreciated.
    --Ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Do not use default logger as getLoggers[0] , but use your java.util.Logger.FileHandler and add filehandler object to log your fButtonActions and you do not need to mess with logger.properties too.

  • Doubt in java.util.logging

    Hi,
    I have doubt in logging api provided in java 1.4.
    I have a simple program to get the logger and output log into it.
    This is how the program looks.
    LogTest.java
    import java.util.logging.*;
    import java.util.*;
    public class LogTest {
    public static void main(String args[]) {
         LogManager manager = LogManager.getLogManager();
         Logger l = manager.getLogger("global");
         System.out.println(l);
         l.severe("Test");
         System.out.println(manager.getLogger("ivy"));
         System.out.println(manager.getLogger("test"));
    I able to get the instance of the global logger, but im not able to get instance of other logger. I getting null for all the other logger
    test.properites
    =================
    handlers = java.util.logging.ConsoleHandler
    java.util.logging.ConsoleHandler.level=INFO
    java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
    ivy.level = INFO
    .ivy.level = INFO
    =================
    Compilation Command
    java -Djava.util.logging.config.file=C:\WorkSpace\test.properties LogTest Output:
    java.util.logging.Logger@13f5d07
    Jan 25, 2006 7:19:24 PM LogTest main
    SEVERE: Test
    null
    null
    I also tried the same with no config properties, Still im getting the null for logger.
    Can I know is there anything that im missing. Is there any property that must be set or do i hav set some config properties.
    Thanks,
    Siva

    Well, basically that's part of the formatdefinition
    that Properties uses. If you don't do it, then you
    aren't really using Properties format and you'llhave
    to do your own IO.Thanks for the reply. Is there anyother api or class
    that can be used to resolve my problem.What is the problem? A character is escaped, but you will get : when you read the value. You don't have a problem as long as all reading / writing is done through that class.

  • Can't load runtime properties in java.util.logging.LogManager

    This should be so easy, what am I doing wrong?
    I have the following logging.properties located on my classpath:
    handlers=java.util.logging.ConsoleHandler
    .level=INFO
    java.util.logging.ConsoleHandler.level=INFO
    java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
    Test.level=FINE
    Test.handlers=java.util.logging.ConsoleHandlerI have a very simple Test.java file that should load the new properties file and print out the known logger names (ie Test).
    I've also tried putting Test.java in a package, it didn't seem to matter.
    public class Test {
      public Test() {
        String name = this.getClass().getName();
        //this properties file is should be sitting in same dir as Test class
        java.io.InputStream is = this.getClass().getResourceAsStream("logging.properties");
        try {
          //get log manager instance
          java.util.logging.LogManager lm = java.util.logging.LogManager.getLogManager();
          //read the new configuration
          lm.readConfiguration(is);
          //print out list of logger names
          java.util.Enumeration e = lm.getLoggerNames();
          while (e.hasMoreElements()) {
            System.out.println(e.nextElement());
          //print logger for this class!
          System.out.println("getLogger("+name+"): "+lm.getLogger(name));
        } catch (Exception e) {
        } finally {
          try {
            is.close();
            is = null;
          } catch (Exception e) {}
      public static void main(String[] args) {
        Test test1 = new Test();
    }The output I get from this is a single logger name, and then null for my desired Test logger.
    global
    getLogger(Test): null

    It seems a logger instance HAS been created for my Test class, I've added the lines below. Though it didn't appear in the logger names enumeration.
    java.util.logging.Logger logger = java.util.logging.Logger.getLogger(name);
    System.out.println(logger.getName()+"="+logger.getLevel().getName());
    logger.severe("severe");
    logger.warning("warning");
    logger.info("info");
    logger.config("config");
    logger.fine("fine");
    logger.finer("finer");
    logger.finest("finest");Output:Test=FINEST
    6/10/2003 16:00:01 Test <init>
    SEVERE: severe
    6/10/2003 16:00:01 Test <init>
    WARNING: warning
    6/10/2003 16:00:01 Test <init>
    INFO: infoObservations:
    1) Despite my Test class having the FINEST log level, the default ConsoleHandler had log level of INFO, and hence only up to INFO logged.

  • OracleLog.properties for java.util.logging

    In the Oracle JDBC FAQ the answer to the question "How do I configure java.util.logging to get useful trace output from Oracle JDBC?" <http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#36_03> mentions the file "OracleLog.properties" provided in the "demo.zip" file.
    I cannot find the file "OracleLog.properties" anywhere?
    Any suggestions?
    Kindest Regards,
    Gerhard Hofmann

    It seems a logger instance HAS been created for my Test class, I've added the lines below. Though it didn't appear in the logger names enumeration.
    java.util.logging.Logger logger = java.util.logging.Logger.getLogger(name);
    System.out.println(logger.getName()+"="+logger.getLevel().getName());
    logger.severe("severe");
    logger.warning("warning");
    logger.info("info");
    logger.config("config");
    logger.fine("fine");
    logger.finer("finer");
    logger.finest("finest");Output:Test=FINEST
    6/10/2003 16:00:01 Test <init>
    SEVERE: severe
    6/10/2003 16:00:01 Test <init>
    WARNING: warning
    6/10/2003 16:00:01 Test <init>
    INFO: infoObservations:
    1) Despite my Test class having the FINEST log level, the default ConsoleHandler had log level of INFO, and hence only up to INFO logged.

  • Help with java.util.logging SocketHandler - Simple TCP Server

    I have a simple TCP serverString clientSentence;
                 ServerSocket welcomeSocket = new ServerSocket(5050);
                 while(true) {
                    Socket connectionSocket = welcomeSocket.accept();
                    BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
                    while ((clientSentence = inFromClient.readLine()) != null) {
                         System.out.println("Received: " + clientSentence);
                 }And I have a java.util.logging logger using a SocketHandler. I'm just calling logger.log("my message"); I get the expected result to System.out: "my message". But when I go on to call again logger.log("my next message") I get both messages in queue: "my message" and "my next message" on the next line. So, I get from these two calls to logger.log() the following result in System.out
    my message
    my message
    my next message...whereas I expected
    my message
    my next messageWhy is "my message" being saved even after being passed through the TCP connection to the server? I tried handler.flush() but that doesn't help. Pretty sure the problem isn't at the server end because when I create two loggers with their own SocketHandlers the server doesn't double up on their messages. (In other words, if I let one logger say simply "my message" and the second logger say "my next message" I get the expected output. It's like each logger needs to be flushed after sending to the server.
    Any advice appreciated.

    Yes, I was just rereading your post and it's apparent that you were suspecting the client code. Your posting only the server led me to believe that you were focusing on that and I kind of skipped over the last part.
    So to answer your question, yes, the server code looks okay. And you were suspecting the client anyway, so problem solved.

  • Using the java.util.logging in JDK1.3

    I would like to use the java.util.logging classes of JDK1.4 in JDK1.3. So I tried creating a new jar with only the java.util.logging package, however, javac generates the error:
    >>>>>>
    bad class file: E:\ThinClient\Log\logging.jar(java/util/logging/Logger.class)
    class file has wrong version 48.0, should be 47.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    <<<<<<<
    I tried placing the jar both in classpath and bootclasspath during javac and still was not successful, is there any way of getting around this, other than re-implementing this or getting some third parties implementation such as Apache's log4j?

    check out Lumberjack in sourceForge

  • Unable to capture messages from java.util.logging

    I have a class called (Caller.java) which invokes a method called foo from another java class(Util.java) using reflection API.Now this method foo logs messages using Java's logger.My requirement is to call foo for 3 times from Caller and capture/redirect the log messages into 3 log files.
    But only the first log file is capturing the log messages(from logger) and other two are not ?
    Plz suggest if I am doing somethin wrong here ?
    Caller.java
    package project2;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.PrintStream;
    import java.lang.reflect.Method;
    public class Caller {
        public Caller() {
        public static void main(String[] args) throws Exception {
            Caller caller = new Caller();
            for (int i = 0 ;i<3 ;i++ )  {
                caller.createLogStream(i);
                System.setOut(caller.getPs());
                System.setErr(caller.getPs());
                /*****************Invoking Util.java*****************************/
                Class clas = Class.forName("project2.Util");
                Method m = clas.getMethod("foo",null);
                Object obj =clas.newInstance();
                m.invoke(obj,null);
        public void createLogStream(int i) throws FileNotFoundException {
            ps = new PrintStream(new File(System.getenv("HOME")+File.separator+"MyLog"+i+".log"));
        public void closeLogStream(){
            ps.close();
            ps = null;
        private PrintStream ps = null;
        public PrintStream getPs() {
            return ps;
    } Util.java
    package project2;
    import java.util.logging.Logger;
    public class Util {
        Logger logger = null;
        public Util() {
            logger = Logger.getLogger(this.getClass().getName());
        public void foo(){
            System.out.println("Hello out stream");
            System.err.println("Hello error stream");
            logger.info("This is an information");
            logger.warning("This is a warning message");
            logger.severe("This is fatal!! ");
    }First Log file MyLog0.log:
    Hello out stream
    Hello error stream
    Feb 16, 2009 7:55:55 PM project2.Util foo
    INFO: This is an information
    Feb 16, 2009 7:55:55 PM project2.Util foo
    WARNING: This is a warning message
    Feb 16, 2009 7:55:55 PM project2.Util foo
    SEVERE: This is fatal!!
    Feb 16, 2009 7:55:55 PM project2.Util foo
    INFO: This is an information
    Feb 16, 2009 7:55:55 PM project2.Util foo
    WARNING: This is a warning message
    Feb 16, 2009 7:55:55 PM project2.Util foo
    SEVERE: This is fatal!!
    Feb 16, 2009 7:55:55 PM project2.Util foo
    INFO: This is an information
    Feb 16, 2009 7:55:55 PM project2.Util foo
    WARNING: This is a warning message
    Feb 16, 2009 7:55:55 PM project2.Util foo
    SEVERE: This is fatal!! Other 2 log files have only this much
    Hello out stream
    Hello error stream

    A stale Connection Factory or Connection Handle may be used in SOA 11g
    Regards,
    Anuj

  • Java.util.logging.XMLFormatter - need advise

    Hi all,
    I have this class which suppose to write some message into the custom log file (in XML). Problem is, after the first time of writing it into the same file, it will append additional XML header :
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE log SYSTEM "logger.dtd">
    Worse, it will always append below.
    For example, the original XML file contains:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE log SYSTEM "logger.dtd">
    <log>
    <record>
      <date>2010-10-20T18:18:33</date>
      <millis>1287569913671</millis>
      <sequence>0</sequence>
      <logger>atm.controller.Log_Controller</logger>
      <level>INFO</level>
      <class>atm.controller.Log_Controller</class>
      <method>writeInfoLog</method>
      <thread>10</thread>
      <message>message inside thia standard data</message>
    </record>
    </log>when I write additional message into the same file using logger.info("some message"); on the second rounds, it will append additional XML header* info and become like this:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE log SYSTEM "logger.dtd">
    <log>
    <record>
      <date>2010-10-20T18:18:33</date>
      <millis>1287569913671</millis>
      <sequence>0</sequence>
      <logger>atm.controller.Log_Controller</logger>
      <level>INFO</level>
      <class>atm.controller.Log_Controller</class>
      <method>writeInfoLog</method>
      <thread>10</thread>
      <message>message inside thia standard data</message>
    </record>
    </log>
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE log SYSTEM "logger.dtd">
    <log>
    <record>
      <date>2010-10-20T18:21:25</date>
      <millis>1287570085050</millis>
      <sequence>0</sequence>
      <logger>atm.controller.Log_Controller</logger>
      <level>INFO</level>
      <class>atm.controller.Log_Controller</class>
      <method>writeInfoLog</method>
      <thread>10</thread>
      <message>message inside thia standard data</message>
    </record>
    </log>--------------------------------------------------
    Below is the code.
    import java.io.IOException;
    import java.util.logging.FileHandler;
    import java.util.logging.Logger;
    import java.util.logging.XMLFormatter;
    public class Log_Controller
        private static Logger logger = Logger.getLogger( Log_Controller.class.getName() );
        private boolean allowAppend = true;
        public Log_Controller()
            try
                XMLFormatter formatterTxt = new XMLFormatter();
                FileHandler fileTxt = new FileHandler( "test.xml", allowAppend );
                fileTxt.setFormatter( formatterTxt );
                logger.addHandler( fileTxt );
            catch ( IOException ioe )
                ioe.printStackTrace();
        public void writeInfoLog( String message )
            logger.info("message inside thia standard data");  //THIS IS THE PART WHERE IT WRITE SOME MESSAGE INTO THE FILE
    //        logger.info( message );
    }This is something new to me, appreciate if someone can point me what the mistake that I have done.
    Thanks thanks.
    Edited by: 803699 on 20-Oct-2010 04:15
    Edited by: 803699 on 20-Oct-2010 08:45

    you cannot append to an xml file using the standard formatter because it makes the log file a "complete xml document" (header and root wrapper tags). if you want to be able to append to an existing xml log file, you will need to roll your own formatter.

  • Can't create log file with java.util.logging

    Hi,
    I have created a class to create a log file with java.util.logging
    This class works correctly as standalone (without jdev/weblogic)
    import java.io.IOException;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.logging.*;
    public class LogDemo
         private static final Logger logger = Logger.getLogger( "Logging" );
         public static void main( String[] args ) throws IOException
             Date date = new Date();
             DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
             String dateStr = dateFormat.format(date);
             String logFileName = dateStr + "SEC" + ".log";
             Handler fh;          
             try
               fh = new FileHandler(logFileName);
               //fh.setFormatter(new XMLFormatter());
               fh.setFormatter(new SimpleFormatter());
               logger.addHandler(fh);
               logger.setLevel(Level.ALL);
               logger.log(Level.INFO, "Initialization log");
               // force a bug
               ((Object)null).toString();
             catch (IOException e)
                  logger.log( Level.WARNING, e.getMessage(), e );
             catch (Exception e)
                  logger.log( Level.WARNING, "Exception", e);
    }But when I use this class...
    import java.io.File;
    import java.io.IOException;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.logging.FileHandler;
    import java.util.logging.Handler;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import java.util.logging.XMLFormatter;
    public class TraceUtils
      public static Logger logger = Logger.getLogger("log");
      public static void initLogger(String ApplicationName) {
        Date date = new Date();
        DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
        String dateStr = dateFormat.format(date);
        String logFileName = dateStr + ApplicationName + ".log";
        Handler fh;
        try
          fh = new FileHandler(logFileName);
          fh.setFormatter(new XMLFormatter());
          logger.addHandler(fh);
          logger.setLevel(Level.ALL);
          logger.log(Level.INFO, "Initialization log");
        catch (IOException e)
          System.out.println(e.getMessage());
    }and I call it in a backingBean, I have the message in console but the log file is not created.
    TraceUtils.initLogger("SEC");why?
    Thanks for your help.

    I have uncommented this line in logging.properties and it works.
    # To also add the FileHandler, use the following line instead.
    handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandlerBut I have another problem:
    jdev ignore the parameters of the FileHandler method .
    And it creates a general log file with anothers log files created each time I call the method logp.
    So I play with these parameters
    fh = new FileHandler(logFileName,true);
    fh = new FileHandler(logFileName,0,1,true);
    fh = new FileHandler(logFileName,10000000,1,true);without succes.
    I want only one log file, how to do that?

  • Java.util.logging - different log files for different loggers

    I'm having trouble configuring Java logging to use different log files for different loggers.
    In log4j, I would do this by configuring multiple loggers each with a different appender. But how can I do this with Java (java.util.logging) logging?
    This is the basic idea of what I'd like to do:
    com.mycompany.app1.level = FINEST
    com.mycompany.app1.<log file> = logfile1.log
    com.mycompany.app2.level = ALL
    com.mycompany.app2.<log file> = logfile2.log
    Any suggestions?

    This kind of thing?
    import java.io.IOException;
    import java.util.logging.FileHandler;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import java.util.logging.SimpleFormatter;
    public class LogTest {
        private Logger app1;
        private Logger app2;
        public LogTest() {
            // setup loggers
            try {
                // first logger
                app1 = Logger.getLogger("com.mycompany.app1");
                FileHandler filehandler = new FileHandler( "logfile1.log" );
                filehandler.setFormatter(new SimpleFormatter());
                app1.addHandler(filehandler);  
                // second logger       
                app2 = Logger.getLogger("com.mycompany.app2");
                filehandler = new FileHandler( "logfile2.log" );
                filehandler.setFormatter(new SimpleFormatter());
                app2.addHandler(filehandler);  
            } catch(IOException ioex) {
                ioex.printStackTrace();
        private void logStuff() {
            app1.log(Level.SEVERE, "a message for log 1");
            app2.log(Level.SEVERE, "a message for log 2");
            app2.log(Level.WARNING, "another message for log 2");
         * @param args
        public static void main(String[] args) {
            new LogTest().logStuff();
    }

  • Where to find .jar files so I can implement import java.util.logging

    I'm trying to figure out how to take an application built for Websphere and port it to WebLogic. I've come across this blog entry http://blogs.sun.com/fkieviet/entry/using_java.util.logging_in_bea_weblogic and would like to try creating and using the startup class.
    I have not been able to find the correct jar files.
    import weblogic.common.T3ServicesDef;
    import weblogic.common.T3StartupDef;
    import weblogic.logging.LoggingHelper;
    In reading the documentation on using the NonCatalogLogger APIs at http://download.oracle.com/docs/cd/E12840_01/wls/docs103/i18n/writing.html I also see some code calling for the following imports
    import weblogic.jndi.Environment;
    import weblogic.logging.NonCatalogLogger;
    1. Does anyone know where I can grab these?
    2. There must be a strategy for finding these .jars that people use. If so, what is it?

    I thought I understood you, but the more I look at what you've set here, I'll just be honest and admit that the I don't know what you are saying here:
    'You should be able to add the "weblogic.jar" in the WebLogic distribution to your classpath.' - What doe this mean?
    1. Go to my xxxWeb app Dynamic Web Project and right-click and select Build Path / Configure Build Bath / Libraries - Select Add external JARS and navigate to the weblogic.jar
    2. Go to my xxxWeb app Dynamic Web Project and right-click and select Build Path / Configure Build Bath / Libraries - Select Add Library and try to go from there?
    3. Go to my xxxWeb app Dynamic Web Project and right-click and select Build Path / Configure Build Bath / Libraries - Select Add Variable and try to go from there?
    4. Go to my xxxWeb app Dynamic Web Project and right-click and select Build Path / Configure Build Bath and do something else?
    5. Something else?
    Also, I don't know what you mean here:
    'You don't need to (and you shouldn't) copy that jar file, just have it in your compilation classpath. It will be present automatically at runtime.'
    Sorry for being so simple here but I've been trouble shooting why I can't follow what look like pretty simple steps to implement over-riding the ApplicationLifecycleListener Class to use existing java.util.logging.Logger code by adding the following to the the weblogic-application.xml:
    <wls:listener>
         <wls:listener-class>com.qualcomm.weblogic.log.listener.UtilLogWrapper</wls:listener-class>
    </wls:listener>
    And including as a referenced jar file, a simple POJO class instance of com.qualcomm.weblogic.log.listener.UtilLogWrapper.
    My resrouces for this are:
    1. http://blogs.sun.com/fkieviet/entry/using_java.util.logging_in_bea_weblogic.
    2. http://www.oracle.com/technology/pub/articles/drolet-ant.html.
    Maybe my weblogic.jar is at the root of the problem.
    I hope you can 'dumb this down' for me with a simple explanation of steps to do what you outlined above.

  • How to prevent java.util.logging from displaying pop-up dialog on SEVERE?

    Hi,
    I'm new to using java.util.logging. I notice that whenever I try to make a call to logger.SEVERE(msg) or logger.WARNING(msg), not only does it write the output to file (which I want), but it also pops up a dialog box displaying the exception. I don't want this pop up to appear. How do I prevent the logger from doing this?

    What are you talking about?
    Hello,
    In order to better assist you with your issue please provide us with a screenshot. If you need help to create a screenshot, please see [[How do I create a screenshot of my problem?]]
    Once you've done this, attach the saved screenshot file to your forum post by clicking the '''Browse...''' button below the ''Post your reply'' box. This will help us to visualize the problem.
    Thank you!

  • Java.util.logging - Problem with setting different Levels for each Handler

    Hello all,
    I am having issues setting up the java.util.logging system to use multiple handlers.
    I will paste the relevant code below, but basically I have 3 Handlers. One is a custom handler that opens a JOptionPane dialog with the specified error, the others are ConsoleHandler and FileHandler. I want Console and File to display ALL levels, and I want the custom handler to only display SEVERE levels.
    As it is now, all log levels are being displayed in the JOptionPane, and the Console is displaying duplicates.
    Here is the code that sets up the logger:
    logger = Logger.getLogger("lib.srr.applet");
    // I have tried both with and without the following statement          
    logger.setLevel(Level.ALL);
    // Log to file for all levels FINER and up
    FileHandler fh = new FileHandler("mylog.log");
    fh.setFormatter(new SimpleFormatter());
    fh.setLevel(Level.FINER);
    // Log to console for all levels FINER and up
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.FINER);
    // Log SEVERE levels to the User, through a JOptionPane message dialog
    SRRUserAlertHandler uah = new SRRUserAlertHandler();
    uah.setLevel(Level.SEVERE);
    uah.setFormatter(new SRRUserAlertFormatter());
    // Add handlers
    logger.addHandler(fh);
    logger.addHandler(ch);
    logger.addHandler(uah);
    logger.info(fh.getLevel().toString() + " -- " + ch.getLevel().toString() + " -- " + uah.getLevel().toString());
    logger.info("Logger Initialized.");Both of those logger.info() calls displays to the SRRUserAlertHandler, despite the level being set to SEVERE.
    The getLevel calls displays the proper levels: "FINER -- FINER -- SEVERE"
    When I start up the applet, I get the following in the console:
    Apr 28, 2009 12:01:34 PM lib.srr.applet.SRR initLogger
    INFO: FINER -- FINER -- SEVERE
    Apr 28, 2009 12:01:34 PM lib.srr.applet.SRR initLogger
    INFO: FINER -- FINER -- SEVERE
    Apr 28, 2009 12:01:40 PM lib.srr.applet.SRR initLogger
    INFO: Logger Initialized.
    Apr 28, 2009 12:01:40 PM lib.srr.applet.SRR initLogger
    INFO: Logger Initialized.
    Apr 28, 2009 12:01:41 PM lib.srr.applet.SRR init
    INFO: Preparing Helper Files.
    Apr 28, 2009 12:01:41 PM lib.srr.applet.SRR init
    INFO: Preparing Helper Files.
    Apr 28, 2009 12:01:42 PM lib.srr.applet.SRR init
    INFO: Getting PC Name.
    Apr 28, 2009 12:01:42 PM lib.srr.applet.SRR init
    INFO: Getting PC Name.
    Apr 28, 2009 12:01:42 PM lib.srr.applet.SRR init
    INFO: Finished Initialization.
    Apr 28, 2009 12:01:42 PM lib.srr.applet.SRR init
    INFO: Finished Initialization.Notice they all display twice. Each of those are also being displayed to the user through the JOptionPane dialogs.
    Any ideas how I can properly set this up to send ONLY SEVERE to the user, and FINER and up to the File/Console?
    Thanks!
    Edit:
    Just in case, here is the code for my SRRUserAlertHandler:
    public class SRRUserAlertHandler extends Handler {
         public void close() throws SecurityException {
         public void flush() {
         public void publish(LogRecord arg0) {
              JOptionPane.showMessageDialog(null, arg0.getMessage());
    }Edited by: compbry15 on Apr 28, 2009 9:44 AM

    For now I have fixed the issue of setLevel not working by making a Filter class:
    public class SRRUserAlertFilter implements Filter {
         public boolean isLoggable(LogRecord arg0) {
              if (arg0.getLevel().intValue() >= Level.WARNING.intValue()) {
                   System.err.println(arg0.getLevel().intValue() + " -- " + Level.WARNING.intValue());
                   return true;
              return false;
    }My new SRRUserAlertHandler goes like this now:
    public class SRRUserAlertHandler extends Handler {
         public void close() throws SecurityException {
         public void flush() {
         public void publish(LogRecord arg0) {
              Filter theFilter = this.getFilter();
              if (theFilter.isLoggable(arg0))
                   JOptionPane.showMessageDialog(null, arg0.getMessage());
    }This is ugly as sin .. but I cannot be required to change an external config file when this is going in an applet.
    After much searching around, this logging api is quite annoying at times. I have seen numerous other people run into problems with it not logging specific levels, or logging too many levels, etc. A developer should be able to complete configure the system without having to modify external config files.
    Does anyone else have another solution?

Maybe you are looking for