• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to append and limit the size of log file using java.util.logging  RSS feed

 
s ravi chandran
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i have an issue with the logging file, I am using FileHandler for putting all the logs in to a file. I want to add timestamp to the log file name.. now, i have seen the FileHandler constructor which seems useful to me,



but in this, I am unable to create the pattern, if i add something randomly, the logger doesnt work, i.e. nothing is written to the logging file..
any ideas?
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may seem like the path of least resistance, but unless you have a really good reason to opt for JDK logging and implementing all this yourself, I'd suggest you go with something like Log4J instead.
It already has FileAppenders that work perfectly and it also supports lots of different and configurable output formats.
If you don't want to tie your code directly to the Log4J API you could use a wrapper solution like SLF4J or Apache Commons Logging.
 
s ravi chandran
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jelle Klap wrote:This may seem like the path of least resistance, but unless you have a really good reason to opt for JDK logging and implementing all this yourself, I'd suggest you go with something like Log4J instead.
It already has FileAppenders that work perfectly and it also supports lots of different and configurable output formats.
If you don't want to tie your code directly to the Log4J API you could use a wrapper solution like SLF4J or Apache Commons Logging.


Thanks for replying. I am indeed using JDK logging to make the application independent of any library requirements. we are working in a secure environment, where we don't have internet and bringing a library jar or any other software is very difficult. So, I am aiming to do the logging task with the JDK logger itself, in case there are few things which might be required and is not available in built-in logging then only I would opt for third party jar library.

I have worked with log4j in the past though. its just that I wanted to see if JDK built-in logging can do the work for me or not.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!