Where is the SQL trace log

122 Views Asked by At

I am trying to find the logs about all the SQL queries that run when a DQL is executed. If I try to execute this from the API tester it works, and I can see the logs. But the difference is that I run that directly from the remote machine, while here I connect to it from my local machine.

        String docbase = props.getProperty("dfc.docbase.name");
        String username= props.getProperty("dfc.username");
        String password = props.getProperty("dfc.password");
        IDfSession session = SessionUtil.getSession(docbase,username,password);

The question is where are the logs when I try to run it from the library. I tried

    public static void enable(IDfSession session) throws DfException{
        IDfApplySetOptions applyCommand = (IDfApplySetOptions) DfAdminCommand.getCommand(IDfAdminCommand.APPLY_SET_OPTIONS);
        applyCommand.setOption("rpctrace");
        applyCommand.setValue(true);
        applyCommand.execute(session);
    }

and

public static boolean enable2(IDfSession session) throws DfException{
        IDfCollection coll = null;
        try {
            coll = session.apply(
                    null,
                    "SET_OPTIONS",
                    new DfList(new String[]{"OPTION", "VALUE", }),
                    new DfList(new String[]{"S", "B", }),
                    new DfList(new String[]{"rpctrace", "T", }));
            if (coll.next() && coll.hasAttr("result")) {
                return coll.getBoolean("result");
            }
            return false;
        } finally {
            if (coll !=null) {
                coll.close();
            }
        }

    }

Full code

public static void main(String[] args) throws IOException, DfException, FileNotFoundException {
        Properties props = new Properties();
        props.load(Main.class.getResourceAsStream("/config.properties"));

        String docbase = props.getProperty("dfc.docbase.name");
        String username= props.getProperty("dfc.username");
        String password = props.getProperty("dfc.password");
        IDfSession session = SessionUtil.getSession(docbase,username,password);

        SessionUtil.enable2(session);
1

There are 1 best solutions below

1
On

You can enable SQL traces on the server side (logged to repository log) by enabling SQL trace on IAPI:

apply,c,NULL,SET_OPTIONS,OPTION,S,sqltrace,VALUE,B,T

Or you can set up local traces by adding the following configuration to your local dfc.properties:

dfc.tracing.enable=true
dfc.tracing.verbose=true
dfc.tracing.max_stack_depth=0
dfc.tracing.mode=compact
dfc.tracing.dir=/tmp/dfc_tracing