Logging server messages (custom servers)
You can capture custom server messages from your Amazon GameLift Servers custom servers in log files. To learn about logging for Amazon GameLift Servers Realtime, see Logging server messages (Amazon GameLift Servers Realtime).
Important
There is a limit on the size of a log file per game session (see Amazon GameLift Servers endpoints and quotas in the Amazon Web Services General Reference). When a game session ends, Amazon GameLift Servers uploads the server logs to Amazon Simple Storage Service (Amazon S3). Amazon GameLift Servers will not upload logs that exceed the limit. Logs can grow very quickly and exceed the size limit. You should monitor your logs and limit the log output to necessary messages only.
Configuring logging for custom servers
With Amazon GameLift Servers custom servers, you write your own code to perform logging, which you configure as part of your server process configuration. Amazon GameLift Servers uses your logging configuration to identify the files that it must upload to S3 at the end of each game session.
The following instructions show how to configure logging using simplified code examples:
Writing to logs
Your log files exist after your server process has started. You can write to the logs using any method to write to files. To capture all of your server's standard output and error output, remap the output streams to log files, as in the following examples:
Accessing server logs
Log access varies by fleet type:
Managed EC2 fleets
When a game session ends, Amazon GameLift Servers automatically stores the logs in an S3 bucket and retains them for 14 days. To get the location of the logs for a game session, you can use the GetGameSessionLogUrl API operation. To download the logs, use the URL that the operation returns.
Alternatively, you can set up your own logging solution by configuring your game server to send logs directly to your preferred logging service or storage location. For more information, see Communicate with other Amazon resources from your fleets.
Container fleets
Container fleets capture standard output and error streams from all containers. You can configure logging using one of these options:
-
Save container output as CloudWatch log streams in a specified log group
-
Save container output to an S3 storage bucket
-
Turn off logging (container output isn't saved)
For detailed information about configuring logging options when creating container fleets, see LogConfiguration