Logger

Discussion in 'Spigot Plugin Development' started by bys1, Jun 14, 2016.

  1. I've created a logger to log things in a data.log file, but have two problems.

    - It also logs it in the console, is there a way to prevent that?

    - It creates an empty data.log.lck file, how can I prevent that?
     
  2. It also creates data.log.1, data.log.2, ... files now each time I create a new FileHandler. Can't a file handler just use an already existing log file?
     
  3. JamesJ

    Supporter

    Probably because you're creating a new file every time you create the FileHandler..
     
  4.  
  5. JamesJ

    Supporter

    Yes it can, but like I said, you're most likely creating a file every time.
     
  6. This is what I found on StackOverflow:
    Code (Java):

    logHandler = new FileHandler("data.log");
    logHandler.setFormatter( new SimpleFormatter() );
     
     
    #6 bys1, Jun 14, 2016
    Last edited: Jun 14, 2016
  7. MiniDigger

    Supporter

    why not start with telling us what logging api you are using?
     
  8. ..And can you post the code please?
     
  9. Just java.util.logging.Logger
     
  10.  
  11. MiniDigger

    Supporter

  12. MiniDigger

    Supporter

    well, just ignore them. they are required by the internal logger so that multiple instances can't access one file I guess.
     
  13. Is there a way to disable it so multiple FileHandlers can log there instead of creating .log.1, .log.2... Files?