Accessing "trace()" function outside of extension

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

Moderators: Lapo, Bax

Post Reply
clam61
Posts: 125
Joined: 12 Sep 2007, 02:00

Accessing "trace()" function outside of extension

Post by clam61 »

My extensions use some utility classes, and I want these utility classes to be able to log to the smartfoxserver.log as well.

How can I access the trace function or redirect my stdout to the log file?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Accessing "trace()" function outside of extension

Post by rjgtav »

Hello,

One option is to store a static instance of your extension's main class and then everytime you want to trace anything to the console, you retrieve that instance and call the appropriate method.
Another one is to directly access the logger, if I'm not mistaken, you can use the Logger.getLogger("SmartFoxServer") command for retrieving SFS's logger.

Cheers
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
clam61
Posts: 125
Joined: 12 Sep 2007, 02:00

Re: Accessing "trace()" function outside of extension

Post by clam61 »

is it from the java.util.logging package?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Accessing "trace()" function outside of extension

Post by rjgtav »

Hello,

Yes you can use that Logger. And retrieve the logger for SmartFoxServer's class "it.gotoandplay.smartfoxserver.SmartFoxServer".
But as this logger is more reserved to the server-side API, I'd really suggest to go the first way I explained on my previous post, by exposing an instance of your extension and then logging through it.

Cheers
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Post Reply