• 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
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Java logger config file not working.

 
Ranch Hand
Posts: 146
Mac OS X IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Been a long while ;)

I have this simple Java logging script:

which I initialise from a another script. In this I am trying to change the format of the SimpleFormatter through this properties file:

It starts off by saying "initializing the config file", and then outputs nothing else, even though there is more log lines. This means it is getting stuck on something. I am using this website: https://www.logicbig.com/tutorials/core-java-tutorial/logging/customizing-default-format.html and I have tried the top two methods. I also have tried my best to do debugging and try other methods, but I can't get it to work.

What can I do to change the format of the SimpleFormatter?

Thanks,
Bod
 
Bod McLeon
Ranch Hand
Posts: 146
Mac OS X IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahh, figured it out.
I ended up using this line:

and all I had to to was put it like this:

so that is was after the SimpleFormatter was created, but before it was applied to the logger.
 
Bod McLeon
Ranch Hand
Posts: 146
Mac OS X IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, never-mind. I noticed that it was using the new format when writing to the console, but it wasn't in the log file created. I did a few changes to the error handling, and it's not even creating a log anymore (after I deleted the old one). I have a feeling that it wasn't writing the new format to the log because it wasn't even writing anything to the log. I don't know this for certain because I didn't look at the time stamps, but I bet they wouldn't have changed. Here's the new code:

What could be happening?
 
Sheriff
Posts: 7113
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the late reply.

I don't think your FileHandle name is what you want.  I did this:
and the log file was updated where I expected it to.
 
I think I'll just lie down here for a second. And ponder this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic