Create method of Logging to O/S from Container
[aaf/authz.git] / auth / auth-gui / src / main / java / org / onap / aaf / auth / gui / AAF_GUI.java
index be93d63..676866b 100644 (file)
@@ -25,6 +25,8 @@ import static org.onap.aaf.auth.rserv.HttpMethods.GET;
 import static org.onap.aaf.auth.rserv.HttpMethods.POST;
 import static org.onap.aaf.auth.rserv.HttpMethods.PUT;
 
+import java.io.File;
+
 import javax.servlet.Filter;
 
 import org.onap.aaf.auth.cmd.Cmd;
@@ -68,6 +70,7 @@ import org.onap.aaf.auth.gui.pages.WebCommand;
 import org.onap.aaf.auth.rserv.CachingFileAccess;
 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.LocatorException;
 import org.onap.aaf.cadi.PropAccess;
@@ -254,10 +257,21 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
        }
 
        public static void main(final String[] args) {
-               PropAccess propAccess = new PropAccess(args);
                try {
-                       AAF_GUI service = new AAF_GUI(new AuthzEnv(propAccess));
-//                     env.setLog4JNames("log4j.properties","authz","gui","audit","init","trace ");
+                       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, "authz");
+                       PropAccess propAccess = new PropAccess(logIt,args);
+               
+                       AAF_GUI service = new AAF_GUI(new AuthzEnv(propAccess));
                        JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
                        jss.start();
                } catch (Exception e) {