use of alma.acs.logging.config.LogConfig in project ACS by ACS-Community.
the class AcsLoggerHelper method setHibernateSqlLogLevels.
public void setHibernateSqlLogLevels(AcsLogLevelDefinition localLevel, AcsLogLevelDefinition remoteLevel) {
LogConfig logConfig = ClientLogManager.getAcsLogManager().getLogConfig();
String name = HibernateLoggerHelper.HIBERNATE_SQL_LOGGER_NAME_PREFIX + '@' + loggerName;
logConfig.setMinLogLevelLocal(localLevel, name);
logConfig.setMinLogLevel(remoteLevel, name);
}
use of alma.acs.logging.config.LogConfig in project ACS by ACS-Community.
the class AcsLoggerHelper method setDefaultLogLevels.
/**
* Sets levels for normal loggers, which otherwise are configured by xsd defaults, $ACS_LOG_STDOUT etc,
* but not by this class.
*/
public void setDefaultLogLevels(AcsLogLevelDefinition localLevel, AcsLogLevelDefinition remoteLevel) {
LogConfig logConfig = ClientLogManager.getAcsLogManager().getLogConfig();
logConfig.setDefaultMinLogLevelLocal(localLevel);
logConfig.setDefaultMinLogLevel(remoteLevel);
}
use of alma.acs.logging.config.LogConfig in project ACS by ACS-Community.
the class ManagerEngine method initializeManager.
/**
* Initialize and activate Manager.
*/
private void initializeManager() throws Throwable {
logger = ClientLogManager.getAcsLogManager().getLoggerForApplication("Manager", true);
logger.info("Initializing Manager.");
//
// CORBA
//
// obtain CORBA Service
corbaService = new DefaultCORBAService(logger);
// get ORB
final ORB orb = corbaService.getORB();
if (orb == null) {
CoreException ce = new CoreException("CORBA Service can not provide ORB.");
throw ce;
}
// get RootPOA
POA rootPOA = corbaService.getRootPOA();
if (rootPOA == null) {
CoreException ce = new CoreException("CORBA Service can not provide RootPOA.");
throw ce;
}
//
// Remote Directory
//
NamingServiceRemoteDirectory remoteDirectory = new NamingServiceRemoteDirectory(orb, logger);
Context context = null;
if (remoteDirectory != null)
context = remoteDirectory.getContext();
//
// Initialize CORBA
//
// set USER_ID, PERSISTENT policies
org.omg.CORBA.Policy[] policies = new org.omg.CORBA.Policy[2];
/*
// set USER_ID, PERSISTENT,BIDIRECTIONAL policies
org.omg.CORBA.Policy [] policies = new org.omg.CORBA.Policy[3];
*/
policies[0] = rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID);
policies[1] = rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT);
/*
// create BIDIRECTIONAL policy
Any bidirValue = orb.create_any();
BidirectionalPolicyValueHelper.insert(bidirValue, BOTH.value);
policies[2] = orb.create_policy(BIDIRECTIONAL_POLICY_TYPE.value, bidirValue);
*/
// create ManagerPOA
managerPOA = rootPOA.create_POA("ManagerPOA", rootPOA.the_POAManager(), policies);
// destroy policies
for (int i = 0; i < policies.length; i++) policies[i].destroy();
// initialize Manager implementation
// allow object reference serialization
CORBAReferenceSerializator.setOrb(orb);
manager = new ManagerImpl();
manager.setDomain(MANAGER_DOMAIN);
recoveryLocation = FileHelper.getTempFileName(null, RECOVERY_DIR_NAME);
String readRecovery = System.getProperties().getProperty("Manager.recovery", "true");
if (readRecovery.equalsIgnoreCase("false")) {
// if we are not interested in recovery files just delete them
File recoveryDir = new File(recoveryLocation);
//recoveryDir.delete();
File[] files = recoveryDir.listFiles();
for (int i = 0; files != null && i < files.length; i++) files[i].delete();
// Now check if there are log files left. Maybe user do not have enough permision
// or we are didn't set proper permission before Manager killed.
// That can lead to unwanted or illegal state so we will refuse to continue
files = recoveryDir.listFiles();
for (int i = 0; files != null && i < files.length; i++) {
if (files[i].getName().endsWith(".commandLog"))
throw new Exception("Some recovery files are left in recovery location probably because of permission\nUnable to start without recovery state!");
}
} else {
// remove old recovery files
RecoveryFilesRemover.removeRecoveryFiles(new File(recoveryLocation));
}
SnapshotPrevayler prevayler = null;
if (isPrevaylerDisabled) {
System.out.println("Prevayler disabled!");
} else {
prevayler = new SnapshotPrevayler(manager, recoveryLocation);
if (readRecovery.equalsIgnoreCase("false")) {
// just to invalidate prevaylers message
System.out.println("Skipping saved manager state!");
}
manager = (ManagerImpl) prevayler.system();
}
CDBAccess cdbAccess = new CDBAccess(orb, logger);
LogConfig logConfig = ClientLogManager.getAcsLogManager().getLogConfig();
logConfig.setCDBLoggingConfigPath("MACI/Managers/Manager");
logConfig.setCDB(cdbAccess.connectAndGetDAL());
try {
logConfig.initialize(false);
} catch (LogConfigException ex) {
// if the CDB can't be read, we still want to run the manager, so
// we only log the problems
logger.log(Level.FINE, "Failed to configure logging (default values will be used). Reason: " + ex.getMessage());
}
// initialize manager "mock" container services
ManagerContainerServices managerContainerServices = new ManagerContainerServices(orb, managerPOA, cdbAccess.getDAL(), logger);
manager.initialize(prevayler, cdbAccess, context, logger, managerContainerServices);
manager.setShutdownImplementation(shutdownImplementation);
// setup ORB profiling
try {
if (orb instanceof AcsProfilingORB) {
AcsORBProfiler profiler = new ManagerOrbProfiler(manager, logger);
((AcsProfilingORB) orb).registerAcsORBProfiler(profiler);
logger.finer("Orb profiling set up, using class " + ManagerOrbProfiler.class.getName());
}
} catch (Throwable th) {
logger.log(Level.WARNING, "Failed to setup ORB profiling.", th);
}
if (prevayler != null) {
FileHelper.setFileAttributes("g+w", recoveryLocation);
// create new task for snapshoot creation,
final long MINUTE_IN_MS = 60 * 1000;
new RecoverySnapshotTask(prevayler, 1 * MINUTE_IN_MS, recoveryLocation, manager.getStatePersitenceFlag());
}
// initialize Manager CORBA Proxy (create servant)
managerProxy = new ManagerProxyImpl(manager, logger);
//activate object
managerPOA.activate_object_with_id(MANAGER_ID, managerProxy);
// get object reference from the servant
org.omg.CORBA.Object obj = managerPOA.servant_to_reference(managerProxy);
managerReference = ManagerHelper.narrow(obj);
// get IOR
String ior = orb.object_to_string(managerReference);
// notify user
logger.info("Manager activated with " + ior);
// register special service components to the Manager
manager.setManagerComponentReference(managerReference);
// set transport
manager.setTransport(new CORBATransport(orb, ior));
// register NameService
if (remoteDirectory != null) {
String reference = remoteDirectory.getReference();
if (reference != null) {
// convert iiop to corbaloc
if (reference.startsWith("iiop://")) {
reference = reference.replaceFirst("iiop://", "corbaloc::");
if (reference.charAt(reference.length() - 1) != '/')
reference += "/NameService";
else
reference += "NameService";
}
}
try {
obj = NamingContextHelper.narrow(orb.string_to_object(reference));
} catch (Exception ex) {
// Something went wrong getting the NS
logger.log(Level.SEVERE, "Error getting the NameServer. Manager exiting...");
this.shutdownImplementation.shutdown(false);
}
manager.setRemoteDirectoryComponentReference(obj);
}
// intitialize federation here - after remote directory is set (if it is)
// (this is not a nice solution)
Hashtable federationDirectoryProperties = new Hashtable();
// set CosNamingFactory
federationDirectoryProperties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
// set orb
federationDirectoryProperties.put("java.naming.corba.orb", orb);
manager.initializeFederation(federationDirectoryProperties);
// initialize remote logging
new Thread(new Runnable() {
public void run() {
ClientLogManager.getAcsLogManager().initRemoteLogging(orb, managerReference, manager.getHandle(), true);
}
}, "Remote logging initializer").start();
manager.initializationDone();
}
use of alma.acs.logging.config.LogConfig in project ACS by ACS-Community.
the class ClientLogManagerTest method testHibernateLoggerConfig.
public void testHibernateLoggerConfig() throws Exception {
LogConfig sharedLogConfig = clientLogManager.getLogConfig();
// default levels < WARNING for first hibernate logger, should result in custom levels WARNING
sharedLogConfig.setDefaultMinLogLevelLocal(AcsLogLevelDefinition.TRACE);
sharedLogConfig.setDefaultMinLogLevel(AcsLogLevelDefinition.DEBUG);
AcsLogger hibernateLogger1 = clientLogManager.getLoggerForCorba("hibernate", true);
assertLogLevels(hibernateLogger1, AcsLogLevelDefinition.WARNING, AcsLogLevelDefinition.WARNING);
assertTrue(sharedLogConfig.hasCustomConfig(hibernateLogger1.getLoggerName()));
// default levels >= WARNING for second hibernate logger, should result in custom levels equal to default levels
sharedLogConfig.setDefaultMinLogLevelLocal(AcsLogLevelDefinition.ERROR);
sharedLogConfig.setDefaultMinLogLevel(AcsLogLevelDefinition.WARNING);
AcsLogger hibernateLogger2 = clientLogManager.getLoggerForCorba("hibernateSql", true);
assertLogLevels(hibernateLogger2, AcsLogLevelDefinition.ERROR, AcsLogLevelDefinition.WARNING);
assertTrue(sharedLogConfig.hasCustomConfig(hibernateLogger2.getLoggerName()));
// ClientLogManager should create new hibernate loggers ,no reuse
assertNotSame("Hibernate logger reuse should happen inside org.slf4j.impl.ACSLoggerFactory, but not in ClientLogManager.", hibernateLogger1, hibernateLogger2);
}
use of alma.acs.logging.config.LogConfig in project ACS by ACS-Community.
the class LocalOnlyAcsLogger method getInstance.
public static synchronized LocalOnlyAcsLogger getInstance(String namespace, Level level) {
if (instance == null) {
LogConfig testLogConfig = new LogConfig();
testLogConfig.setDefaultMinLogLevelLocal(AcsLogLevel.getNativeLevel(level).getAcsLevel());
instance = new LocalOnlyAcsLogger(namespace, testLogConfig);
instance.setUseParentHandlers(false);
Handler logHandler = new StdOutConsoleHandler(testLogConfig, namespace, null);
logHandler.setFormatter(new AcsXMLLogFormatter() {
public String format(LogRecord lr) {
String xml = super.format(lr);
return xml + '\n';
}
});
logHandler.setLevel(level);
instance.addHandler(logHandler);
}
return instance;
}
Aggregations