33. Game operation part 3: Logging player activity

Logs left on the game server generally fall into the following two categories: 1) logs for program debugging and 2) user activity logs for customer support.

There are many more of the former and they are only needed when there is a server problem, even though they are saved in the DB. There are relatively few of the latter, but they must be persistently stored in the DB. iFun Engine supports both debugging and player activity logs.

This chapter will cover player activity logs. For more about debugging logs, see Programming part 1: Debugging logs.

33.1. Activity Logger Overview

Since gameplay that must be logged is different for each game, iFun Engine uses a logger function to record activity logs in the form of JSON files. Programmers can now use that logger to leave logs. Activity logs are managed separately from program logs using MongoDB or JSON.


If the game runs on iFun Deploy, activity log files are collected and saved in the DB.

33.2. Activity logger definition files

If we make a project called funapi_initiator my_project, a JSON file defining the logger is made with the name src/my_project_loggers.json.

Logs are defined with the following structure in this file.

  "LogType1": {
    "Argument1": "Type1"

  "LogType2": {
    "Argument1": "Type1",
    "Argument2": "Type2"

For example, you can set using the following method.

  "SessionOpened": {
    "session_id": "string",
    "when": "datetime2"
  "SessionClosed": {
    "session_id": "string",
    "when": "datetime2"
  "PlayerLoggedIn": {
    "session_id": "string",
    "account_id": "string",
    "when": "datetime2"
  "PlayerDropItem": {
    "player_name": "string",
    "item_name": "string"

33.2.1. Activity logger type parameters

The following can be used with the type value.






Real number form


Integer form


Text string form


date type (time_t form)


data type (WallClock::Value form)

33.3. Automatically generated logger function

When defined and compiled as above, the following logger function is automatically generated.

namespace logger {

void SessionOpened(const string &session_id, const WallClock::Value &when);
void SessionClosed(const string &session_id, const WallClock::Value &when);
void PlayerLoggedIn(const string &session_id, const string &account_id, const WallClock::Value &when);
void PlayerDropItem(const string &player_name, const string &item_name);

}  // namespace logger

가령 플레이어가 아이템을 떨굴 때마다 이제 logger:PlayerItemDrop() 을 호출하면 됩니다.

class ActivityLog {

  public void SessionOpened(string arg_session_id, System.DateTime arg_when);
  public void SessionClosed(string arg_session_id, System.DateTime arg_when);
  public void PlayerLoggedIn(string arg_session_id, string arg_account_id, System.DateTime arg_when);
  public void PlayerLoggedIn(string arg_player_name, string arg_item_name);


가령 플레이어가 아이템을 떨굴 때마다 이제 ActivityLog.PlayerItemDrop() 을 호출하면 됩니다.

33.3.1. Parameter type and programming language type matching

Each activity logger type matches a programming language type, as follows.

Logger type

C++ type

C# type


const bool



const double



const int64_t



const string &






const WallClock::Value &


33.4. Activity logger save location

Activity logs are saved in MANIFEST.json.

File, DB, and Syslog format are available.

The following is an example of MANIFEST.json.

"Logging": {
  "activity_log_output": "json://activity_log/test",
  "activity_log_rotation_interval": 60

In the example above, log location differs depending on activity_log_output value. The following are available.

33.4.1. Output as standard I/O

  • stdout: Log output as standard output.

  • stderr: Log output as standard error.

33.4.2. Redirect to another logger

  • glog: Combined with glog created by program log and output. (For more details, please see Programming part 1: Debugging logs.)

  • syslog://procname: Output as syslog’s INFO level. Here, procname is the program name. This feature only works in Linux.

33.4.3. Saving in files

  • file://path/to/filename: Under the directory path/to/date, a file is created in the form filename.time, and each field is delimited by a comma one line at a time.

  • json://path/to/file: Similar to files but each line delimited by a comma is created in JSON format rather than as a log.


The file format is generated in a particular directory called log root, and the rules for this are as follows.

  • At the development stage, it is in the activity_log/ directory under the build directory.

  • At the live stage, it is in /var/log/funapi/{{ project_name }}/activity_log.

33.4.4. Saving in the DB

2020년 2월을 기준으로 Activity loggerMongoDB v3.0 이상 v4.0 이하의 버전을 지원합니다. 만약, MongoDB 를 직접 설치해야 하는 경우 `MongoDB 커뮤니티 에디션 설치<https://docs.mongodb.com/manual/installation/>`_ 를 참고하시기 바랍니다.

  • mongodb://user:passwd@host:port/database: MongoDB 의 특정 database 에 로그를 생성합니다. user, password, port 등의 정보는 선택적인 정보입니다. 예를 들어 mongodb://localhost:27017/my_activity_log 와 같은 형태가 될 수 있습니다. Replica set 지정등을 위한 보다 자세한 URI pattern 에 대해서는 MongoDB 공식 문서의 연결 문자열 항목을 참고해주세요.

    MongoDB 에 로그를 남기기 위해서는 아이펀 엔진에서 제공하는 libfunapi1-mongodblogger 패키지를 추가로 설치 해 주시기 바랍니다.

    • Ubuntu:

      sudo apt-get install libfunapi1-mongodblogger
    • CentOS:

      sudo yum install funapi1-mongodblogger

    또한, MANIFEST.jsonMongoDbBase 항목을 추가해야합니다.

    "Logging": {
      "activity_log_output": "mongodb://localhost:27017/activity_log",
    "MongoDbBase": {
       "mongodb_logger_enable_ssl": false


    SSL/TLS 연결이 필요한 경우 mongdb_logger_enable_ssl 옵션을 true 로 변경해야 합니다.

33.5. Activity logger parameters

Add the following to a MANIFEST.json Logging session.

  • activity_log_output: Activity log storage path. As explained above, the following values are available.

    • stdout

    • stderr

    • glog

    • syslog://name

    • file://path/to/file

    • json://path/to/file

    • mongodb://user:passwd@host:port


    Syslog only works in Linux.

  • activity_log_rotation_interval: Cycle in seconds to rotate activity logs. (type=int32, default=60)

  • activity_log_write_schema: Whether or not schema data is output to activity logs (type=bool, default=true)