• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SocketHandler / BufferedReader question

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm writing a simple client/server application that will make use of logging over a network. My client sends LogRecord objects to a SocketHandler which sends XML data to the server. For some reason when I read the data on the server I'm not getting the closing tag for the root element, </log>.

I'm basing my code on this example posted on Sun's website. Running their code will demonstrate the problem. I duplicated their code below...

Client


Server


Is there something I'm missing here? Thanks.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that the element </log> is the tail of the log message according to the XmlFormatter.
The message tail is appended only when you close the handler.
Since, you have programatically added the handler to the logger, you need to close it programatically. So, if you add handler.close() as the last statement in your client, you will get the end element also.
The other option is to specify the handler in the logging.properties file. If you do this the handler will automatically be close when VM exits.
 
J. Ryan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. That fixed it!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic