Exception management

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
briphi
Posts: 3
Joined: 24 Jan 2008, 13:58

Exception management

Post by briphi »

I'm having some trouble handling exceptions, and am getting quite confused in the process.

I'm trying to handle my own exceptions, and I want to log them to a file. Is there a way to access the stack trace data (which smartfoxserver prints when we don't catch the exception), so that I can log it myself?

Is there a solution that works with exceptions that originate from either javascript or java?

Bascially, I want to create a high level try/catch that will catch all exceptions and log their stack trace.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

No I am sorry, this is not possible.
If you can give us more details about what you are trying to do we could offer more help
Lapo
--
gotoAndPlay()
...addicted to flash games
Boing
Posts: 59
Joined: 11 Apr 2008, 14:57

Post by Boing »

well, isn't this rather problematic?
I just experienced the problem that I saw an exception on the console but did not find it in the log.
Is some information written only to the console? :shock:

I don't know if this might cause problems but I am messing around with the SFS loggers a bit in order to integrate it to my Log4J system like this:

Code: Select all

        // remove SFS log handlers
        Handler[] handlers = SmartFoxServer.log.getHandlers();
        if (handlers != null && handlers.length > 0) {
            for (int i = 0; i < handlers.length; i++) {
                SmartFoxServer.log.removeHandler(handlers[i]);
            }
        }
        // redirect SFS logging to Log4J
        SmartFoxServer.log.addHandler(new SFSLog4JLogger());
        SmartFoxServer.log.setUseParentHandlers(false);
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

If you run the server as a service everything gets logged.
That's the recommended mode for running the server in a production environment.
I don't know if this might cause problems but I am messing around with the SFS loggers a bit in order to integrate it to my Log4J system like this:
Log4J will replace the java default logging system in the next major update. :)
Lapo
--
gotoAndPlay()
...addicted to flash games
Boing
Posts: 59
Joined: 11 Apr 2008, 14:57

Post by Boing »

Lapo wrote:If you run the server as a service everything gets logged.
That's the recommended mode for running the server in a production environment.
okay, and when not running as a service? Stacktraces get swallowed?

We currently have our own start script, I think because we had problems with the default one when we started.

Code: Select all

screen -h 5000 -dmS jumpjupiter java -server -Xms1024m -Xmx2048m -enableassertions -cp ${CLASSPATH} [...] it.gotoandplay.smartfoxserver.SmartFoxServer
Are there good reasons to change this?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Simply use this instead:
./sfs start (or stop, restart, console)
Lapo
--
gotoAndPlay()
...addicted to flash games
Boing
Posts: 59
Joined: 11 Apr 2008, 14:57

Post by Boing »

Since our script does some more stuff it won't be just "simply".
That's why I want to find out if it's worth it - what are the advantages? Or is it the same in the end?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Exceptions are always logged to log files depending on your logging level config. Stack traces are not.

We do output to console a few stack traces for extra debugging. Those are captured by running the server as we recommend.
Lapo
--
gotoAndPlay()
...addicted to flash games
Boing
Posts: 59
Joined: 11 Apr 2008, 14:57

Post by Boing »

okay, that's at least one good reason.
Simply using your script did not work on the first attempt, but I'll try to get it running on the weekend.
I saw some threads handling the topic. In case I don't get the problems solved I'll post there.
Thanks for your answers, Lapo.
Post Reply