Page 1 of 1

Remove unneeded logs

Posted: 12 Jul 2016, 05:59
by GrinReaper
We are getting these logs printed frequently whenever we use the client and it hampers ours debugging effort since it creates an unnecessary clutter among the logs that we need to debug.

Code: Select all

Handling Header Size. Length: 376 (small)
14:53:55,583 INFO  [sfs2x.client.core.SFSIOHandler] (New I/O  worker #1) Data size is 94
14:53:55,583 INFO  [sfs2x.client.core.SFSIOHandler] (New I/O  worker #1) Handling Data: 374, previous state: 0/94
14:53:55,583 INFO  [sfs2x.client.core.SFSIOHandler] (New I/O  worker #1) <<< Packet Complete >>>
14:53:55,584 INFO  [sfs2x.client.core.SFSIOHandler] (New I/O  worker #1) Handling New Packet of size 280
14:53:55,584 INFO  [sfs2x.client.core.SFSIOHandler] (New I/O  worker #1) Handling Header Size. Length: 279 (small)
Is there any way to stop the client from printing these logs so that we can have only our own logs in the log file and the console?

Re: Remove unneeded logs

Posted: 12 Jul 2016, 07:31
by Lapo
Hi,
the SmartFox class constructor takes one Boolean parameter that toggles the debug info. You can use:

Code: Select all

SmartFox sfs = new SmartFox(false);

Re: Remove unneeded logs

Posted: 12 Jul 2016, 09:13
by GrinReaper
We've already used set the debug flag as false in the code. But we're still getting the logs that I've mentioned. The other SFS logs are not printed, but only those lines still keep getting printed.

Re: Remove unneeded logs

Posted: 12 Jul 2016, 13:37
by Lapo
Are you using the ConfigData object to start the connection? If so make sure to also set ConfigData.isDebug = false

Thanks

Re: Remove unneeded logs

Posted: 13 Jul 2016, 06:18
by GrinReaper
This is the code that we use to connect:

Code: Select all

sfs = new SmartFox(false);
sfs.connect("192.168.132.25",9933);
We're not using ConfigData object to connect. :?

Re: Remove unneeded logs

Posted: 13 Jul 2016, 07:44
by Lapo
Try using this instead:

Code: Select all

ConfigData cd = new ConfigData();
cd.setHost("192.168.132.25");
cd.setDebug(false);

sfs.connect(cd);
Thanks

Re: Remove unneeded logs

Posted: 13 Jul 2016, 09:11
by GrinReaper
Even that didn't work. We're still getting the logs. :(

Re: Remove unneeded logs

Posted: 13 Jul 2016, 10:38
by Lapo
What version of the Java API are you using?
I'd recommend using the latest, if you're not up to date:
http://smartfoxserver.com/download/sfs2x#p=client

I am testing with the current version (1.6.1) and I can't reproduce the problem you have reported.

Let us know.

Re: Remove unneeded logs

Posted: 13 Jul 2016, 12:32
by GrinReaper
Can you provide us with the test application that you've written? We'd like to compare the code with ours and see what we're doing differently.

Re: Remove unneeded logs

Posted: 13 Jul 2016, 15:07
by Lapo
Sure, here it is:

Code: Select all

package sfs2xjavaclienttest;

import com.smartfoxserver.v2.exceptions.SFSException;
import sfs2x.client.SmartFox;
import sfs2x.client.core.BaseEvent;
import sfs2x.client.core.IEventListener;
import sfs2x.client.core.SFSEvent;
import sfs2x.client.requests.LoginRequest;
import sfs2x.client.util.ConfigData;

public class SFS2XJavaClientTest 
{
    SmartFox sfs;

    public SFS2XJavaClientTest() 
    {
        sfs = new SmartFox();
        sfs.addEventListener(SFSEvent.CONNECTION, new IEventListener() {
            @Override
            public void dispatch(BaseEvent be) throws SFSException {
                System.out.println("Connected");
                
                sfs.send(new LoginRequest(""));
            }
        });
        
        sfs.addEventListener(SFSEvent.LOGIN, new IEventListener() {
            @Override
            public void dispatch(BaseEvent be) throws SFSException {
                System.out.println("Logged in as: " + sfs.getMySelf().getName());
            }
        });
        
        ConfigData cfg = new ConfigData();
        cfg.setHost("localhost");
        cfg.setZone("BasicExamples");
        cfg.setDebug(false);
        
        System.out.println("API Version: " + sfs.getVersion());
        
        sfs.connect(cfg);
    }
    

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) 
    {
        new SFS2XJavaClientTest();
    }
}
Hope it helps

Re: Remove unneeded logs

Posted: 14 Jul 2016, 09:28
by GrinReaper
So, we managed to solve the issue.

The first problem was that we were using an old version of the SFS2X Java client API. So, we downloaded the latest API and tried to use it. Then, we learned that we need to use Java 1.7 instead of Java 1.6 which is what we were using. We updated Java and everything was alright in the world again!

Thank you :)

Re: Remove unneeded logs

Posted: 14 Jul 2016, 09:35
by Lapo
Sorry, I should have probably asked earlier what version you were using ... In any case I am glad you figured it out. :)

cheers