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?

@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.

@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

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.

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

@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.

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).

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