Create method of Logging to O/S from Container
[aaf/authz.git] / auth / auth-locate / src / main / java / org / onap / aaf / auth / locate / AAF_Locate.java
index 92fc88c..31f6772 100644 (file)
@@ -22,6 +22,7 @@
 
 package org.onap.aaf.auth.locate;
 
+import java.io.File;
 import java.net.URI;
 import java.util.Map;
 
@@ -46,6 +47,7 @@ import org.onap.aaf.auth.locate.mapper.Mapper.API;
 import org.onap.aaf.auth.rserv.HttpMethods;
 import org.onap.aaf.auth.server.AbsService;
 import org.onap.aaf.auth.server.JettyServiceStarter;
+import org.onap.aaf.auth.server.Log4JLogIt;
 import org.onap.aaf.cadi.CadiException;
 import org.onap.aaf.cadi.Locator;
 import org.onap.aaf.cadi.LocatorException;
@@ -230,10 +232,21 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
        }
 
        public static void main(final String[] args) {
-               PropAccess propAccess = new PropAccess(args);
                try {
+                       String propsFile = getArg(AAF_LOG4J_PREFIX, args, "org.osaaf")+".log4j.props";
+                       String log_dir = getArg(Config.CADI_LOGDIR,args,"./logs");
+                       String log_level = getArg(Config.CADI_LOGLEVEL,args,"INFO");
+                       File logs = new File(log_dir);
+                       if(!logs.isDirectory()) {
+                               logs.delete();
+                       }
+                       if(!logs.exists()) {
+                               logs.mkdirs();
+                       }
+                       Log4JLogIt logIt = new Log4JLogIt(log_dir,log_level,propsFile, "locate");
+                       PropAccess propAccess = new PropAccess(logIt,args);
+
                        AAF_Locate service = new AAF_Locate(new AuthzEnv(propAccess));
-//                     service.env().setLog4JNames("log4j.properties","authz","gw","audit","init","trace");
                        JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
                        jss.start();
                } catch (Exception e) {