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.

Similar Messages

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

  • Enabling java.util.logging for Toplink

    JDeveloper 10.1.3.0.4 Build 3673 running Embedded OC4J (jdk1.5.0_02).
    I'm trying to get Toplink to log to a custom handler (a la java.util.logging) while running Embedded OC4J, but nothing I've tried works.
    If I use the java.util.logging.LogManager to loop through and print out all of the existing loggers, none of the 145 listed in the Embedded OC4J environment mention anything about toplink. So presumably Toplink is not running in "java" logging mode. I'm not using toplink workbench which seems to have a UI checkbox to enable java logging, and I haven't found a way to turn it on using JDeveloper. I've tried using the system property -Dtoplink.log.destination=JAVA (no effect) and adding my handler to j2ee-logging.xml (couldn't find my custom logging handler class, and won't help anyway if toplink isn't using java.util.logging), and various attempts at hacking sessions.xml with using log-type and java-log elements (I couldn't get them right--xml parse errors).
    What do I need to do to get Toplink to log to a custom handler?
    TIA,
    Clark

    Hi Clark,
    You can use either java or server log when running an application in OC4J.
    1 When you run a CMP application, use system property (e.g. Dtoplink.log.destination=JAVA)
    2 When you run a non CMP server application, use the logging tag in sessions.xml (e.g. <logging xsi:type="server-log"/>)
    You have the following options to get TopLink to log to a custom handler
    1 If you want to do the entire configuration from logging.properties, remove all handlers/loggers declarations from j2ee-logging.xml and in that case all configuration will be from logging.properties
    2 Use a combination of j2ee-logging.xml and logging.properties. You can define certain attributes in j2ee-logging.xml. They are "name", "class", "level", "errorManager", "filter", "formatter" and "encoding", and they correspond to the attributes of java.util.logging.Handler. Attributes in subclasses of Handler are not supported. All other properties for the handler are defined in logging.properties. j2ee-logging.xml is processed on top of logging.properties, which means j2ee-logging.xml takes the precedence for certain attributes/properties. Take FileHandler for an example,
    j2ee-logging.xml:
         <log_handlers>
         <log_handler name='my-handler' class='java.util.logging.FileHandler'
              formatter='java.util.logging.SimpleFormatter' level='INFO'/>
         </log_handlers>
    logging.properties:
         java.util.logging.FileHandler.pattern = %h/java%u.log
         java.util.logging.FileHandler.limit = 10000
         java.util.logging.FileHandler.count = 2
    If there are no properties defined in logging.properties, it will use its default values, which are documented in the FileHandler javadoc.
    Shannon

  • DateFormat in java.util.logging logging.properties - Please help

    Hello
    I have problem with properties file for my logger.
    Everything is ok except one thing: the date format.
    The question is how to say in my application.logging.properties, that the dates should be formated in particular way?
    In log4j it was (is) possible in way like this:
    log4j.appender.R.layout.ConversionPattern=$d{dd-MM-yyyy hh:mm:ss,SSS} %p [%t] %c - %m%nwhen I use java.util.logging I always get the dates in form like this:
    Jan 8, 2004 1:09:42 PMThe question is how to set date format pattern to for example: dd-MM-yyyy hh:mm:ss,SSS using properties file, to have the date in form like this:
    08-01-2004 13:09:42,768Thank You very much.
    Maciek

    Hi,
    did you find out how to do this?
    I'm after the exact same thing.

  • 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 - 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();
    }

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

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

  • Creating a new Handler (java.util.logging API)

    Hi,
    I'm developping a new Handler (extending the java.util.logging.StreamHandler) and I need to get some initialisation properties from the LogManager. I was taking example from the existing Handlers (SocketHandler, FileHandler...) and wanted to use the LogManager.getLevelProperty, getFilterProperty and so on). Unfortunately these methods are not public.
    Is there any good reason for that ? As we are still dealing with a beta version, can't we have them public (same old Open Source problem).
    Antonio

    I am in a similar situation and agree completely with the above comments. Using the LogManager getProperty() is incredibly cumbersome.
    Ciao Ric

  • 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 in 10.1.2

    Hi all. We have a j2ee application deployed on Oracle Application Server Containers for J2EE 10g (10.1.2.0.2) (build 050812.1879). We have used the java.util.logging package for our logging and are currently only able to view those with a level of either Level.SEVERE or Level.INFO. Any ideas how to enable the other levels will be appreciated. thanks

    See: http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/_html/sescfg004.htm#BCGHIECC for an example how to use the logging.properties file to set the logging thresholds.
    Regards, Ronald

  • 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

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

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

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

Maybe you are looking for