0

I am using WebLogic 10.3.3. I want to write a log entry to a database every time one of my web services is called.

My question is, what is the best way to send the log info to the database? if the database is down I don't want the logging code to stop the web service. I dont want my web service to wait or crash should the logging code fail. I want any errors in the logging routine to be completly ignored the the web service code.

I'm not sure how to do this in Java EE on WebLogic. Any suggestions?

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
John
  • 1,852
  • 4
  • 26
  • 49

2 Answers2

0

I suppose you've already given log4j a whirl? Just surround your logging with a try/catch block and it should affect your service.

Peter
  • 171
  • 4
  • Yes, but the code is still waiting while its executing. I just found the @Asynchronous, so I'm guessing that if I make a logging ejb with this then that should work. – John Dec 12 '12 at 20:06
0

Your comment to Peter is along the correct track.

You certainly need a separate service for handling the logging.

You will always have an issue with "what if the logger is down - database or service" losing messages.

What you need to do is set up a JMS queue, most likely with a file based backing store which is the least likely to have a failure. Have your service write to the JMS queue to perform the logging, and have your EJB logger service extract messages from the queue to write to the database.

In that way, the log messages will be stored immediately, without being added to the database necessarily immediately, whilst not requiring your service to wait around for completion of the database commit.

There are ways to write to a JMS queue without waiting for completion response so you can minimise the impact on your service.

I can't remember if 10.3.3 had the policy gateway features or whether that came in 10.3.4, however implementing your client component as a policy would make it easier to apply to each of your services without actually touching your service code and give you a reusable solution.

sweetfa
  • 5,457
  • 2
  • 48
  • 62