Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [SOLVED?] How should i Use Logger, Or Save Error Game Files with Libgdx?  (Read 560 times)
0 Members and 1 Guest are viewing this topic.
Offline Andre Lopes
« Posted 2013-10-19 21:55:00 »

How should i Use Logger, Or Save Error Game Files with Libgdx?

Hi guys, im wondering, how should i make the logger in my game?
Should i have a class that records all errors in a .txt file before it crashes the game or i should use log4j or does libgdx have its own logger?

Whats the best practice???


Thanks Guys!

Im almost there.... Smiley
Offline Cero
« Reply #1 - Posted 2013-10-20 04:16:34 »

+1 on this
is it possible to redirect the stream to a text file before the game exits. We wrote our own stream before but now we wanna try the libgdx logger.

also the debug method never printed anything for me, no matter what level I set. info and error worked though D:

Offline Cero
« Reply #2 - Posted 2013-10-20 04:32:22 »

Ah another thing: calls are asynchron... which is horrible for game debugging

1  
2  
3  
4  
5  
      logger = new Logger("TAG", Logger.DEBUG);
      logger.debug("debug");
      logger.info("info");
      logger.error("error");
      System.out.println("Test\n");

Result:
Quote
TAG: info
Test

TAG: error

also showcases debug missing

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 121
Projects: 4
Exp: 3 years



« Reply #3 - Posted 2013-10-20 04:41:11 »

Hm, I've always used this Gdx.app.log (https://code.google.com/p/libgdx/wiki/ApplicationLogging) and Gdx.app.error and I've never had any problems with it.

@OP exactly why do you need to save error files? Unless you plan on widely distributing the game, and have a method to relay the error message back from other computers to you, it's not really necessary.
If you decide you still need it, check this out.
Offline Cero
« Reply #4 - Posted 2013-10-20 04:45:34 »

@OP exactly why do you need to save error files? Unless you plan on widely distributing the game, and have a method to relay the error message back from other computers to you,
You just answered your own question. Once you sell a game, we have to have a mechanism to learn about crashes, to improve upon code stability.
The Stream to file is actually very easily to do with the default stream, but yeah

maybe we should go log4j

Offline Jeremy
« Reply #5 - Posted 2013-10-20 11:58:00 »

Use a proper logging framework. You can plug in different SPIs\bindings into the framework that will handle the logs differently.

JevaEngine uses this one:
http://www.slf4j.org/

Logs are obviously important, even if you just spit them back to the user. I have had users who experience problems with my applications provide me a log that I would've been left guessing without.

When you want to distribute your software, you can easily No-Operation your logs if you use slf4j with little performance impact by plugging in the No-Operation binding without making any mutations to the code, and just plugging in a different binding.

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Offline Andre Lopes
« Reply #6 - Posted 2013-10-21 02:39:00 »

Use a proper logging framework. You can plug in different SPIs\bindings into the framework that will handle the logs differently.

JevaEngine uses this one:
http://www.slf4j.org/

Logs are obviously important, even if you just spit them back to the user. I have had users who experience problems with my applications provide me a log that I would've been left guessing without.

When you want to distribute your software, you can easily No-Operation your logs if you use slf4j with little performance impact by plugging in the No-Operation binding without making any mutations to the code, and just plugging in a different binding.


Will i have any problems if i just use a .txt File to record bad things?
I plan to run in HTML,desktop and Android
Offline opiop65

JGO Kernel


Medals: 128
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #7 - Posted 2013-10-21 02:40:50 »

No, not really. It all depends on what you want to do. You'll have to make your own logging system if you don't use someone else's, but it all depends upon what you want!

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 121
Projects: 4
Exp: 3 years



« Reply #8 - Posted 2013-10-21 02:56:57 »

@Cero, if he wants the log files to have any sort of effect he will need a way to send log files back to the master server/computer, so if he doesn't know networking or anything it might not be worth it, especially if it's not a long term project.
Offline Jeremy
« Reply #9 - Posted 2013-10-21 03:49:02 »

Use a proper logging framework. You can plug in different SPIs\bindings into the framework that will handle the logs differently.

JevaEngine uses this one:
http://www.slf4j.org/

Logs are obviously important, even if you just spit them back to the user. I have had users who experience problems with my applications provide me a log that I would've been left guessing without.

When you want to distribute your software, you can easily No-Operation your logs if you use slf4j with little performance impact by plugging in the No-Operation binding without making any mutations to the code, and just plugging in a different binding.

Will i have any problems if i just use a .txt File to record bad things?
I plan to run in HTML,desktop and Android

Nope, but keep in mind:

- Logging frameworks (like slf4j) batch I/O operations to logging repositories (i.e, a text file) rather than write per function call. This prevents them from consuming a lot of CPU time when you're in the middle of a time-sensitive task (like rendering\updating)
- If you use slf4j, you can very easily change your binding, so if you want to (for example) print the logs to a console, save them to a file, dispatch them to a server or ignore them, you can do that without altering any of your existing code (and just swapping bindings).

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (75 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (80 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (81 views)
2014-04-14 15:48:38

tom_mai78101 (105 views)
2014-04-10 04:04:31

BurntPizza (165 views)
2014-04-08 23:06:04

tom_mai78101 (261 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!