ACS logging APIs C Java Bogdan Jeram bjerameso
ACS logging APIs: C++ & Java Bogdan Jeram (bjeram@eso. org) European Southern Observatory January 2007 ESO, Garching
Architecture Application (non C++ & python) ACS log SVC Application (C++) macro 08/03/2021 L A o g C g I E n g L o g g I n g p r o x y Centralized logger Notification (Telecom Log COS) channel Client jlog client local cache - file stdout - screen 2
Logging System in C++ • based on ACE logging • defined callback (Logging. Proxy) • defined macros • implementation of Centralized Log e. g. Telecom Log CORBA service • ACS Log SVCS 08/03/2021 3
Initialisation • should be done in every thread ! • already done by the Container and the Simple client • Logging. Proxy m_logger (cache. Size, min. Cache. Prio, max. Cache. Prio); Logging. Proxy: : init (&m_logger); • additional configuration: host name, centralized logger, … • Logging. Proxy: : done(); 08/03/2021 4
C++ log macros Generic: ACS_LOG (flag, routine, log) log: ACE log message: (log type, msg) 08/03/2021 5
ACE log messages • Flags: – LM_RUNTIME_CONTEXT – LM_SOURCE_INFO • Log types and default priorities: – – – – – LM_TRACE (2) LM_DEBUG (3) LM_INFO (4) LM_NOTICE (5) LM_WARNING (6) LM_ERROR (8) LM_CRITICAL (9) LM_ALERT (10) LM_EMERGENCY (11) 08/03/2021 6
C++ log macros Specialized: • ACS_DEBUG( routine, msg) • ACS_DEBUG_PARAM (routine, msg, param) • ACS_TRACE (routine) • AUTO_TRACE (routine) • ACS_SHORT_LOG (log) 08/03/2021 7
Examples of creating a message • ACS_DEBUG( "Baci. Test. Class: : ~Baci. Test. Class“, "COB destroyed“ ); • ACS_LOG(LM_RUNTIME_CONTEXT, "maci: : Activator. Impl: : init", (LM_INFO, "Activator '%s' initialized successfuly", m_activator_name) ); • ACS_SHORT_LOG((LM_ALERT, ”Device %d not responding”, dev. Num)) 08/03/2021 8
Configuring • at construction time: Logging. Proxy • via the Configuration Database • environment variables: – set the priority for sending logs to stdout: ACS_LOG_STDOUT – set the file for the local cache: ACS_LOG_FILE 08/03/2021 9
ACS log service • started with: acs. Start. ORBSVC • access to the ACS logging system if native support for logging is not available • reference can be obtained via the Manager (ACSLog. Svc) 08/03/2021 10
Plain JDK Logger with ACS behind the scenes Application code (component or comp-client) get. Logger uses java. util. logging. Logger • info(String msg) • log(Level, String msg, Throwable) Container. Services#get. Logger() creates & configures forwards messages VM-local ACS log handler 19. November 2002 forwards (XML) remote ACS logging service Central log display 12
Code Snippets from jcontexmpl/Hello. Lamp. Impl m_logger. info("say. Hello called. . . "); catch (Exception ex) { m_logger. log(Level. SEVERE, "ex in set. Lamp. Brightness impl", ex); } 19. November 2002 13
JDK Logging API • Standard since JDK 1. 4 • Easy API (you’ll only need the Logger class) – short methods with level names (finest, . . . info, warning, severe) each taking a message string. – More powerful methods log, logp, for logging of values etc. • Flexible configuration for filtering and formatting (done by ACS) • Automatic retrieval of method names, line numbers etc (not guaranteed to work always for all VMs though…) 19. November 2002 14
ACS logging configuration • Standard configuration file used: module acsjlog/src/almalogging. properties acs. Start. Container –java frodo. Container • User may specify different properties file: abeans. Start -endorsed -Djava. util. logging. config. file= /x/y/mylogging. properties frodo. Container • Suppress log levels below INFO (or any other level): alma. acs. logging. Acs. Logging. Handler. level = INFO • Console output level controlled by separate property: java. util. logging. Console. Handler. level = INFO 19. November 2002 15
Exercises • Put into your example some log message: – trace messages: ACS_TRACE – debug message: ACS_DEBUG – try to replace ACS__TRACE/ACS_DEBUG with ACS_LOG (try different combination of flags) • play with environment variables: – ACS_LOG_STDOUT – ACS_LOG_FILE • try jlog client 08/03/2021 16
References • Logging and Archiving: http: //www. eso. org/~gchiozzi/Alma. Acs/Online. Docs/Logging_and_Archiving. pdf • logging doxygen documentation: $ACSROOT/man/cpp/logging_8 h. html • ACS Log SVCS doxygen documentation: $ACSROOT/man/idl/acslog_8 idl. html 08/03/2021 17
- Slides: 16