Create method of Logging to O/S from Container
[aaf/authz.git] / auth / auth-fs / src / main / java / org / onap / aaf / auth / fs / AAF_FS.java
index 5079139..719daaa 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.aaf.auth.fs;
 
 import static org.onap.aaf.auth.rserv.HttpMethods.GET;
 
+import java.io.File;
 import java.io.IOException;
 
 import javax.servlet.Filter;
@@ -36,6 +37,7 @@ import org.onap.aaf.auth.rserv.CachingFileAccess;
 import org.onap.aaf.auth.rserv.HttpCode;
 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.Access.Level;
 import org.onap.aaf.cadi.CadiException;
 import org.onap.aaf.cadi.LocatorException;
@@ -102,10 +104,21 @@ public class AAF_FS 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, "fs");
+                       PropAccess propAccess = new PropAccess(logIt,args);
+               
                        AAF_FS service = new AAF_FS(new AuthzEnv(propAccess));
-//                     env.setLog4JNames("log4j.properties","authz","fs","audit","init",null);
                        JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
                        jss.insecure().start();
                } catch (Exception e) {