Menu

#6 Logging to a rotating set of files

open
nobody
None
5
2014-07-10
2003-03-31
Anonymous
No

My logging properties read

# Properties for the FileHandler
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 3
java.util.logging.FileHandler.pattern = %u/java%u.log
java.util.logging.FileHandler.append = true

What I am trying to do is log to a file called
c:\\logfiles\\mylog.txt, but have the rotating log property.
When I log the first time it creates a file called
mylog.txt.0.0 with the log info. The next time I log I get a
new file called mylog.txt.1.0 created when I really want
the info upto 50 KB to be logged in mylog.txt.0.0 file.
Not sure what the count is for also

Am sending my code also:

Logger logger = Logger.getLogger("TestNewLogger.jsp");
FileHandler fh = new FileHandler
("c:\\logfiles\\mylog.txt",true);
SimpleFormatter simpleFormat = new SimpleFormatter();
fh.setFormatter(simpleFormat);
logger.addHandler(fh);
logger.setLevel(Level.ALL);
logger.severe("FILE OUTPUT");
fh.close();

Please advise

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.