• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Using Multiple Loggers for SimpleFormatting AND XML

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems that if I create two Logger objects, one using SimpleFormatting for the FileHandler, and the other using XMLFormatting for the FileHandler, and try to write to the same file (with appending set to true) it creates two separate files:

logtest.log (Simple formatting)
logtest.log.1 (xml formatting)

However, it seems that the .log and .log.1 are always in the order of the Logger that I use (so if I put the xml first and the simple formatting second it will be .log for xml and .log.1 for simple). I'm thinking that it's probably a good idea to just have the simple default to .log and xml to .xml. Is it even possible to use both simple and xml formmated logging on the same file?

I'm planning on letting the end-user have the option to set log style as a context init paramater and suppose I'd like to also allow them to provide the path/name as well. I could let them give a name and then manually append .xml or .log based on the log style but that would be ugly! ie mylog.log would get turned into mylog.log.xml!

My system: uname -a
Linux toshiba 2.6.22-14-generic i686 GNU/Linux

Here's the code I used to test this:

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic