-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.4.0
-
generic
-
generic
Name: szR10032 Date: 09/18/2000
The nsk/logging/FileHandler/FileHandler/flhndlr001 test uses
java.util.logging.FileHandler.pattern = flhndlr001.%g.log
java.util.logging.FileHandler.limit = 20
java.util.logging.FileHandler.count = 3
properties and produces 10 ten-byte log records in one thread.
The test expects this to result in exactly 3 log files (flhndlr001.0.log,
flhndlr001.1.log, flhndlr001.2.log) of 20 bytes length each according to used
properties. However, 4 log files (flhndlr001.0.log, flhndlr001.0.log.1,
flhndlr001.1.log.1, flhndlr001.2.log.1) are created.
Moreover, flhndlr001.0.log and flhndlr001.0.log.1 files have no info
after the test end so that 2 messages are lost.
Such implementation behavior is not specified by the spec
and is not desired.
See log, source and logging.properties file below.
LOG:
====
novo7% setenv CLASSPATH .:/export/ld24/java/hotspot/Solaris_JDK_1.3/lib/tools.jar:/export/home1/JAVA/__TMP/for_loggingAPIs_jdk
novo7% /export/ld24/java/hotspot/Solaris_JDK_1.3/bin/javac -d . flhndlr001.java
novo7% /export/ld24/java/hotspot/Solaris_JDK_1.3/bin/java -Xbootclasspath/a:/export/home1/JAVA/__TMP/for_loggingAPIs_jdk -Djava.util.logging.config.file=./logging.properties logging.FileHandler.FileHandler.flhndlr001
FAILURE: there should be 3 log files (flhndlr001.0.log, flhndlr001.1.log, flhndlr001.2.log) in test's workdir but 4 are/is found:
flhndlr001.0.log - removed!
flhndlr001.0.log.1 - removed!
flhndlr001.1.log.1 - removed!
flhndlr001.2.log.1 - removed!
TEST FAILED
novo7% ls -l
total 14
-rw-r--r-- 1 zss java 0 Sep 15 2000 flhndlr001.0.log
-rw-r--r-- 1 zss java 0 Sep 15 2000 flhndlr001.0.log.1
-rw-r--r-- 1 zss java 20 Sep 15 2000 flhndlr001.1.log.1
-rw-r--r-- 1 zss java 20 Sep 15 2000 flhndlr001.2.log.1
-rw-r--r-- 1 zss java 2328 Sep 15 18:45 flhndlr001.java
drwxr-xr-x 3 zss java 512 Sep 15 18:44 logging
-rw-r--r-- 1 zss java 192 Sep 15 17:49 logging.properties
novo7%
SOURCE:
=======
package logging.FileHandler.FileHandler;
import java.util.logging.*;
import java.io.*;
public class flhndlr001 {
static LogManager manager;
static FileHandler fh;
static Logger lggr;
public static void main( String argv[] ) {
System.exit(run(argv, System.out)+95); // JCK-compatible exit status
}
public static int run(String argv[],PrintStream out) {
//--------------------------------------------------------------
try {
manager = LogManager.getLogManager();
manager.removeAllGlobalHandlers();
fh = new FileHandler();
fh.setFormatter(new flhndlr001f());
fh.setLevel(Level.FINEST);
lggr = Logger.getLogger("logging.FileHandler.FileHandler.flhndlr001.one");
lggr.addHandler(fh);
lggr.setLevel(Level.FINEST);
} catch (Exception ex) {
System.out.println("TEST FAILED");
return 2; //TEST FAILED
}
//--------------------------------------------------------------
for (int i=0;i<10;i++) {
lggr.finest(i+"123456789");
fh.flush();
}
fh.close();
//--------------------------------------------------------------
File fl;
File cd = new File(".");
String flst[] = cd.list(new flhndlr001l());
int lc = flst.length;
String cf = null;
if (lc != 3) {
System.out.println("FAILURE: there should be 3 log files (flhndlr001.0.log, flhndlr001.1.log, flhndlr001.2.log) in test's workdir but "+lc+" are/is found:");
for (int k=0;k<lc;k++) {
System.out.println(flst[k]+" - removed!");
fl = new File(flst[k]);
// fl.delete();
}
System.out.println("TEST FAILED");
return 2; //TEST FAILED
}
//--------------------------------------------------------------
System.out.println("TEST PASSED");
return 0; //TEST PASSED
}
}
class flhndlr001f extends Formatter {
public java.lang.String format(LogRecord record) {
return record.getMessage();
}
}
class flhndlr001l implements FilenameFilter {
public boolean accept(File dir, String name) {
return (name.indexOf("flhndlr001.") != -1 && name.indexOf(".log") != -1);
}
}
logging.properties:
===================
handlers= java.util.logging.FileHandler
.level= INFO
java.util.logging.FileHandler.pattern = flhndlr001.%g.log
java.util.logging.FileHandler.limit = 20
java.util.logging.FileHandler.count = 3
======================================================================
- relates to
-
JDK-4362603 LOGGING APIs: redundant file is created when property pattern is set
-
- Closed
-