Custom Log File

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

tobaonghiep
Posts: 19
Joined: 01 Feb 2018, 04:33

Custom Log File

Postby tobaonghiep » 03 Apr 2018, 04:01

I would like to separate out the log file by extension. For example:
I have 2 zone MyZone1 and MyZone2. I have a smartfox.log contain all log messages. I would like to config the log4j to filter out the smartfox.log file to MyZone1.log and MyZone2.log to contain only those log come from the zone. There is also MyZone3, MyZone4 can be added at run time and I would like to have a log file for MyZone3 .log and MyZone4.log too after adding the zone.
I would like to ask: Can Smartfox Server able to do that and if it can how could I archive it? Incase it's imposible is there any alternative way?
Sean Su
Mecury Studio
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Custom Log File

Postby Lapo » 03 Apr 2018, 10:50

Hi,
yes it is possible. Take a look here: http://smartfoxserver.com/blog/custom-l ... xtensions/

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
tobaonghiep
Posts: 19
Joined: 01 Feb 2018, 04:33

Re: Custom Log File

Postby tobaonghiep » 03 Apr 2018, 11:10

Hi Lapo,
Follow the tutorial if I have 2 zones I need to config both in properties file. And every time I create a new zone I need to restart the server.
What I need is the server will not be restarted everytime new zone add in and the log file for new zone is create dynamically.
Thanks for your reply
Cheers
Sean Su
Mecury Studio
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Custom Log File

Postby Lapo » 03 Apr 2018, 13:40

Hi,
sorry that's not possible. To change the logging configuration a restart is required.
Lapo

--

gotoAndPlay()

...addicted to flash games
tobaonghiep
Posts: 19
Joined: 01 Feb 2018, 04:33

Re: Custom Log File

Postby tobaonghiep » 05 Apr 2018, 03:00

Hi Lapo,
Let say I don't changing config at logging configuration. is there any custom way that I can have a separated log file for each extension? Do you have any suggestion?

Thanks
Sean Su
Mecury Studio
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Custom Log File

Postby Lapo » 05 Apr 2018, 07:19

Maybe you can try to customize the logger at runtime, though I can't guarantee it will work as we've never tested it and I can't predict what could happen.

In any case Log4J is also configurable from code. You can take a look at their documentation and experiment in your Extension code. In theory you could configure each custom logger inside the init() method of each Extension running in your SmartFox.

Here's an article about configuring Log4J from code:
https://stackoverflow.com/questions/896 ... mmatically

hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 38 guests