• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 595
6
jQuery Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 595
6
jQuery Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Yeast devil! Back to the oven that baked you! And take this tiny ad too:
Master Gardener Program
https://coderanch.com/t/771761/Master-Gardener-Program
reply
    Bookmark Topic Watch Topic
  • New Topic