Bug 3020 - TAO service rolling log files using svc.conf _make_ACE_Logging_Strategy() doesn't work
Summary: TAO service rolling log files using svc.conf _make_ACE_Logging_Strategy() doe...
Status: NEW
Alias: None
Product: TAO
Classification: Unclassified
Component: orbsvcs (show other bugs)
Version: 1.5.9
Hardware: All All
: P3 enhancement
Assignee: DOC Center Support List (internal)
URL:
Depends on:
Blocks:
 
Reported: 2007-07-31 09:48 CDT by Ted Hayes
Modified: 2009-12-29 14:22 CST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ted Hayes 2007-07-31 09:48:38 CDT
Hello

Rolling log files are very useful - I have been trying unsuccessfully to make this work for TAO services e.g. the IMR by adding directives to svc.conf - for example

dynamic Logger Service_Object * ACE:_make_ACE_Logging_Strategy() "-s ./imr/log -f OSTREAM|VERBOSE -N 5 -m 1000 -i 60 -o"

I believe that this is almost working - a Logging_Strategy object is constructed and a timer event handler scheduled.  The problem is that the Logging_Strategy uses ACE_Reactor::instance() as its reactor, but nothing ever starts the reactor run loop.  So no events ever occur and the log just gets bigger.  I guess that all TAO services could be modified to run an event loop for the default Reactor but this is pretty horrible, and could conflict with services' existing use of this reactor..  I can't see how to control installation of a reactor other than the default through the svc.conf mechanism.

In my system I have worked around this by adding code to Logging_Strategy.cpp and rebuilding libACE.so.  In the case where no existing reactor is found and the default reactor is installed into the object in Logging_Strategy::init(), I create a dedicated ACE_TP_Reactor instead and run its event loop with a dedicated ACE_Task thread.  This seems to work and I can now get rolling logs from TAO services, but I'm not sure whether (a) I am just doing the svc.conf bits wrong or (b) there might be a better way.

Please let me know any opinions etc.   I attach the code that I added to Logging_Strategy.cpp for reference..

ACE-TAO version x5.9 running on RH Linux EL4.0.  I have built ACE-TAO using STLport5.1 as the Standard Library.

Thanks and regards
Ted Hayes




//Class LogRollerReactor (singleton instance) bolted into Logging_Strategy.cpp //is used to install a custom TP reactor into the LoggingStrategy and run a //thread to generate events.
#include "ace/TP_Reactor.h"
#include "ace/Task.h"

class LogRollerReactor : public ACE_Task_Base
{
private:
  ACE_Reactor *      m_pReactor;
  ACE_Timer_Heap     m_TimerHeap;

private:
  LogRollerReactor() : ACE_Task_Base(), m_pReactor(NULL)
  {}
public:
  ~LogRollerReactor()
  {
    vStop();

    if (m_pReactor != NULL)
    { delete m_pReactor; }
  }

  virtual int               svc(void);
  static LogRollerReactor & Instance();
  ACE_Reactor *             pReactor();
  void                      vStart();
  void                      vStop();
};

int LogRollerReactor::svc(void)
{ m_pReactor->run_reactor_event_loop(); return 0; }

LogRollerReactor & LogRollerReactor::Instance()
{
  static LogRollerReactor Roller;
  return Roller;
}

ACE_Reactor * LogRollerReactor::pReactor()
{
  if (m_pReactor == NULL)
  {
    ACE_TP_Reactor * pTPReactor = new ACE_TP_Reactor(0, &m_TimerHeap);
    m_pReactor = new ACE_Reactor(pTPReactor, true);
  }
  return m_pReactor;
}

void LogRollerReactor::vStart()
{
  pReactor();
  size_t StackSize[1] = { 32 * 1024 };

  int Status = activate((long)(THR_NEW_LWP | THR_JOINABLE),
                         1, 0, ACE_DEFAULT_THREAD_PRIORITY,
                         -1, NULL, NULL, NULL, &StackSize[0]);
}

void LogRollerReactor::vStop()
{
  if (m_pReactor != NULL)
  { m_pReactor->end_reactor_event_loop(); }
  thr_mgr()->wait();
}



.. code modified in Logging_Strategy::init()

            if (this->reactor () == 0)
              {
                // Use singleton.
                //this->reactor (ACE_Reactor::instance ());
                //
                // Modified to use LogRollerReactor
                LogRollerReactor & rRoller = LogRollerReactor::Instance();
                this->reactor(rRoller.pReactor());
                rRoller.vStart();
              }
Comment 1 Steve Huston 2009-12-29 14:22:51 CST
This should not be changed in the ACE Logging Strategy. It's a documented requirement to run a reactor loop if log rolling is desired. This is an item that should be added to the affected TAO services if log rolling is desired.