6
NRAO - Socorro July, 2004 ACS Course ACS Course ACS logging in ACS logging in Java Java H. Sommer

ACS Course ACS logging in Java

Embed Size (px)

DESCRIPTION

ACS Course ACS logging in Java. H. Sommer. Plain JDK Logger with ACS behind the scenes. Application code (component or comp-client). getLogger. uses. ContainerServices#getLogger(). java.util.logging.Logger info(String msg) log(Level, String msg, Throwable). creates & configures. - PowerPoint PPT Presentation

Citation preview

Page 1: ACS Course ACS logging in Java

NRAO - Socorro July, 2004

ACS CourseACS CourseACS logging in JavaACS logging in Java

H. Sommer

Page 2: ACS Course ACS logging in Java

2

ALMA Project

Socorro, July 2004 ALMA Common Software course

Plain JDK Loggerwith ACS behind the scenes

java.util.logging.Logger• info(String msg)• log(Level, String msg, Throwable)

ContainerServices#getLogger()

Application code(component or comp-client)

creates & configures

getLogger

uses

VM-local ACS log handler

forwards messages

remote ACS logging serviceCentral log display

forwards(XML)

Page 3: ACS Course ACS logging in Java

3

ALMA Project

Socorro, July 2004 ALMA Common Software course

Code Snippetsfrom jcontexmpl/HelloLampImpl

m_logger.info("sayHello called...");

catch (Exception ex)

{

m_logger.log(Level.SEVERE, "ex in setLampBrightness impl", ex);

}

Page 4: ACS Course ACS logging in Java

4

ALMA Project

Socorro, July 2004 ALMA Common Software course

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…)

• API: http://java.sun.com/j2se/1.4.2/docs/api/java/util/logging/package-summary.html

• More info: http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/overview.html

Page 5: ACS Course ACS logging in Java

5

ALMA Project

Socorro, July 2004 ALMA Common Software course

ACS logging configuration

• Standard configuration file used: module acsjlog/src/almalogging.propertiesacsStartContainer –java frodoContainer

• User may specify different properties file:abeansStart -endorsed -Djava.util.logging.config.file=/x/y/mylogging.properties frodoContainer

• Suppress log levels below INFO (or any other level):alma.acs.logging.AcsLoggingHandler.level = INFO

• Console output level controlled by separate property:java.util.logging.ConsoleHandler.level = INFO

Page 6: ACS Course ACS logging in Java

6

ALMA Project

Socorro, July 2004 ALMA Common Software course

Future of Java ACS Logging

• The Logger returned from ContainerServices#getLogger is already configured with a “logger-namespace” unique for the Java component that requests it.

• We could extend that namespace concept to group or filter log entries by the components that produced them

• Log levels for suppressing unimportant messages could be set dynamically, e.g. by the Administrator Client; individually for all components and containers in the system…