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

Similar Messages

  • 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.

  • Unable to capture message from BAPI_REQUIREMENTS_CHANGE in production

    Hi,
    I have written code for uploading PIRu2019s as per demand planner in SAP R/3.
    For this i have used  BAPI_REQUIREMENTS_CREATE and  BAPI_REQUIREMENTS_CHANGE.
    As the command COMMIT WORK is entered within the BAPI, i have not used TRANSACTION_COMMIT bapi.
    It was tested in Development server & working fine in Production server.
    But recently (after 2 months), messages captured from return table of BAPI_REQUIREMENTS_CHANGE, is not coming.
    If any one has faced similar problem, they can guide me to resolve this issue.
    Thanks & regards,
    Tanaya

    Hi Mamta,
    I have already checked that link.
    regards,
    tanaya

  • SLF4J instead of Java Util Logging?

    Hi BDBJE team,
    Is it included on the BDBJE roadmap a migration from "Java Util Logging" to a most flexible framework like SLF4J?
    BR,
    /César.

    Hi Cesar,
    No, definitely not on the road map, but we are aware of the shortcomings of standard Java logging (as documented on this forum) and we will think about what to do about it. It's a little disappointing, given that we just finished moving to standard Java logging (from our own custom logging) in the last release.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Java.util.logging: write to one log file from many application (classes)

    I have a menuapp to launch many applications, all running in same JVM and i want to add logging information to them, using java.util.logging.
    Intention is to redirect the logginginfo to a specific file within the menuapp. Then i want all logging from all applications written in same file. Finally, if needed (but i don't think it is), i will include code to write logging to specific file per app (class). The latter is probably not neccessary because there are tools to analyse the logging-files and allow to select filters on specific classes only.
    The applications are in their own packages/jars and contain following logging-code:
            // Redirect error output
            try {
                myHandler = new FileHandler("myLogging.xml",1000000,2);
            } catch (IOException e) {
              System.out.println("Could not create file. Using the console handler");
            myLogger.addHandler(myHandler);
            myLogger.info("Our first logging message");
            myLogger.severe("Something terrible happened");
            ...When i launch the menuapplication, it writes info to "myLogging.xml.0"
    but when i launch an application, the app writes info to "myLogging.xml.0.1"
    I already tried to leave out the creation of a new Filehandler (try/catch block in code above) but it doesn't help.
    Is it possible to write loginfo to same specific file?

    You should open/close it somehow at every write from different processes.
    But I personally prefer different file names to your forced merging, though.

  • 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 :).

  • 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!

  • Multi-locale support in java.util.logging?

    Can I use log (or logrb) methods in the java.util.logging API to localize my messages to a locale other than the default locale? From what I see in the jdk doc & src, it seems like this is not possible. This kind of multi-locale localization support is essential for server applications that talk to clients from different locales.

    Well, I've never done localization. In case you haven't seen it, here's some documentation from Logger, but that's all I can offer.
    Each Logger may have a ResourceBundle name associated with it. The named bundle will be used for localizing logging messages. If a Logger does not have its own ResourceBundle name, then it will inherit the ResourceBundle name from its parent, recursively up the tree.
    Most of the logger output methods take a "msg" argument. This msg argument may be either a raw value or a localization key. During formatting, if the logger has (or inherits) a localization ResourceBundle and if the ResourceBundle has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used. Typically, formatters use java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two parameters as strings.
    When mapping ResourceBundle names to ResourceBundles, the Logger will first try to use the Thread's ContextClassLoader. If that is null it will try the SystemClassLoader instead. As a temporary transition feature in the initial implementation, if the Logger is unable to locate a ResourceBundle from the ContextClassLoader or SystemClassLoader the Logger will also search up the class stack and use successive calling ClassLoaders to try to locate a ResourceBundle. (This call stack search is to allow containers to transition to using ContextClassLoaders and is likely to be removed in future versions.)
    Formatting (including localization) is the responsibility of the output Handler, which will typically call a Formatter.

  • How is java.util.logging used to log to unix syslog?

    I'm trying to log out to syslog using the java.util.logging that is now in 1.4. I've read all I can find on this topic (not much) and have solicited the used of some syslog free ware (protomatter) but still can't get this to work. I feel like I'm missing something simple here, any help would be appreciated....
    Here is my latest attempt:
    import java.util.logging.*;
    import java.util.*;
    import java.io.*;
    import com.protomatter.syslog.SyslogHandler;
    public class SyslogTest
    public static void main(String argv[]){
    Logger logger2 = Logger.getLogger("local3");
    SyslogHandler ch = new SyslogHandler();
    ch.setLevel(Level.WARNING);
    logger2.addHandler(ch);
    logger2.warning("this is a log message");
    if (logger2.isLoggable(Level.WARNING)) {
    System.out.println("Is LOGGABLE");
    else {
    System.out.println("Is not loggable");
    When this is run nothing is printed to any of the local3 facilities. I've verified that syslog is running fine from the command line using unix logger, so the problem seems to be isolated to my java.
    Thanks.

    Hi,
    What is in your logging.properties file? Can you also include the contents of this file?
    Cheers,
    Craig.

  • 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 java.util.logging Properly

    Hello,
    I have implemented java.util.logging in my application by creating a kind of "wrapper" class that I call for handling logging. It doesn't extend the logging classes, it just provides an object with helper methods that I can call when I want it.
    public class LogCleanerLogger {
        private static final String cleanerLogfile = "logcleanerlog%g.txt";
        private static final String loggerName = "LogCleaner";
        private Logger cleanerLogger = null;
        public LogCleanerLogger() throws IOException{
            this.cleanerLogger = Logger.getLogger(getLoggerName());
            cleanerLogger.setUseParentHandlers(false);
            FileHandler logFile = new FileHandler(getCleanerLogfile(),10000,1, true);
            logFile.setFormatter(new SimpleFormatter());
            cleanerLogger.addHandler(logFile);
        public void writeLogInfoMessage(String message){
            cleanerLogger.info(message);
        public void writeLogWarningMessage(String message){
            cleanerLogger.warning(message);
        public void writeLogErrorMessage(String message){
            cleanerLogger.severe(message);
    // getters and setters
    } // end class    This all works quite happily and I can log any information I want. Except for one thing -- my log directory ends up with the log file (logcleanerlog0.txt) and a list of what appear to be temporary logs, e.g. logcleanerlog0.txt.1, logcleanerlog0.txt.2, and so on. Each increment of the number corresponds to a log file that has progressively less information in it that the previous one. At the top level, the unnumbered log, logcleanerlog0.txt, has all the logged information in it.
    I cannot make out, from reading the API and other documentation, how I can get rid of these other files, which appear to me to be temporary files used in the construction of the top level file.
    Can someone help me by explaining the mechanism for generating these files and either (a) how I can get rid of them altogether or (b) how I can arrange for them to be generated in a temp dir, while keeping the main log in the present directory (application root).
    Or perhaps there is a "better way" (that is equally as easy, of course ;-).
    Thanks.
    mp

    are you sure you cannot use the classes from a newer
    version. You can put those classes in your own
    directory. If there ar some other classes that need to
    be from the newer version, you can include them, also
    in your project. It is important that your project
    directory to be placed in the classpath variable
    before the jdk jars.
    (this solution might not work)I doubt that is worth trying.
    First, although it probably does not apply in this case, you are not allowed to distribute part of a JVM. So you could never use this solution in a commercial application.
    Secondly the Java API does change. And every execution path that might use the changed code would have to be tested. That is going to take a lot of work. Keep in mind that the logging api uses java.lang.String and java.lang.String definitely changed in 1.4 and almost every class in the Java API uses it.

  • Cannot convert from java.util.Date to java.sql.Date

    In the below code am trying to get the current date and 60 days prior date:
    Date  todayDate;
              Date  Sixtydaysprior;
              String DATE_FORMAT = "MM/dd/yy";
              DateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
             Calendar cal = Calendar.getInstance();
              todayDate = sdf.parse(sdf.format(cal.getTime()));
              cal.add(Calendar.DATE, -60);
             Sixtydaysprior = sdf.parse(sdf.format(cal.getTime()));I have imported following files:
    <%@page
         import="java.util.Calendar,
                   java.text.SimpleDateFormat,
                   java.text.ParseException,
                            java.util.*"
    %>Shows up following error msg:
    Type mismatch: cannot convert from java.util.Date to java.sql.Date
    Thanks.
    Edited by: MiltonDetroja on May 22, 2009 11:03 AM

    Shows up following error msg:
    Type mismatch: cannot convert from java.util.Date to java.sql.Date
    I don't think this exception is thrown from the portion of code you have shown. As clearly specified in exception message, you cannot cast an instance of java.util.Date to java.sql.Date. you will need to do something like this
    java.util.Date today = new java.util.Date();
    long t = today.getTime();
    java.sql.Date dt = new java.sql.Date(t);

  • 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?

  • 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 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.

Maybe you are looking for

  • Macro focus on iPhone 5s no longer works

    My iPhone 4 took fantastic macro photos. Jump to I finally upgraded to an iPhone 5s and it did macro images at the beginning but after the first update, it no longer wants to focus. I know it CAN since it will focus to the correct spot then jumps bac

  • Question Concerning Usage of Table Controls

    I currently have three screens. The first screen is the main screen and the other two screens are subscreens called from within the main screen. Inside each of the two subscreens, I have a separate table control. Each table control provides a display

  • Replacing The Hard Drive, How To Install The OS Again?

    Hi all again! Sorry for posting so many questions. I have a macbook pro late 2011 model. I want to replace the hard drive with an SSD drive but I am not too familiar with Mac products. My question is... do I just take out the old hard drive and put t

  • When userenv('CLIENT_INFO') return too much information?

    We just applied some oracle patches and now when when I do a "select trim(userenv('CLIENT_INFO')) from dual", I am getting PETERRA:1389409584404465. All I want/need is JUST the user name (PETERRA). This worked before our DBAs applied the patch(es). I

  • Can i use my mini Mbox 2 with logic pro 9 on iMac os x lion?

    Can i use my mini Mbox 2 with logic pro 9 on iMac os x lion?