SANDBOX — this is a test environment. No servers are actually deployed and no real payments are charged.
Source-checkedAdmin & protection

log4factorio

by xyzzycgn · for Factorio

facility for logging in a mod

2.7KDownloads
5 mo agoLast updated
MITLicense
2.1Latest game version

About log4factorio

From Factorio Mod Portal

facility for logging in a mod

log4factorio:

Slim mod for logging inspired by log4j (but with much less functionality 😉).

This is intended as a facility to be used in other mods – it doesn't add any feature to the played game.

Features

Offers the ability to add log statements which can be enabled/disabled by configuration at _run time_. It supports the following log levels (AKA severities)

  • FATAL

use for logging severe errors

  • ERROR

use for logging major errors

  • WARN

use for logging minor errors

  • INFO

use for logging informational messages

  • CONFIG

use for logging informational messages concerning configuration

  • FINE

use for logging debug messages

  • FINER

use for logging more verbose debug messages

  • FINEST

use for logging very verbose debug messages

FATAL is the highest, FINEST the lowest log level. Let's say log level is configured to INFO, then only all loggging calls with a level of INFO or higher (i.e. FATAL, ERROR, WARN and INFO) will be logged, all others will produce no log entries.

Integration into other mods

  1. include it with require

local Log = require("__log4factorio__.Log")

  1. set the desired log level, either
  • from configuration

Log.setSeverityFromSettings("testmod1-logLevel")

  • or hard coded

Log.setSeverity(Log.WARN)

  1. if using configuration add the appropiate entries to the locale files resp. to settings.lua
    [mod-setting-name]
    testmod1-logLevel=choose log level
    
    [mod-setting-description]
    testmod1-logLevel=all calls with this log level or higher will be logged (FATAL is the highest, FINEST the lowest level)

resp.

    data:extend({
      {
        type = "string-setting",
        name = "testmod1-logLevel",
        order = "zz",
        setting_type = "runtime-global",
        default_value = "CONFIG",
        allowed_values = {
          "FATAL",
          "ERROR",
          "WARN",
          "INFO",
          "CONFIG",
          "FINE",
          "FINER",
          "FINEST",
        }
      },
    })
settings

For more details please have a look at https://wiki.factorio.com/Tutorial:Mod_settings#Locale

  1. Log something

Log.log("sth happened", function(m)log(m)end, Log.INFO)

Log.logLine( { ndx = ndx, wcid = wcid }, function(m)log(m)end, Log.FINE)

Log.logBlock(data, function(m)log(m)end, Log.FINEST)

Assuming that the log level has been set to INFO, that produces entries in factorio-current.log like

137.987 Script @__testMod1__/control.lua:16: [INFO] sth happened

Hints:

  1. If you want to log to the factorio-current.log, use function(m)log(m)end instead of simply log. That offers

the advantage that the logged line number is that from the call in the mod using log4factorio and not the line number from inside log4factorio, where log() is executed 😉.

  1. Due to the mechanisms of factorio when loading mods, all mods using log4factorio use one shared instance during the

data phase, so it may (will) come to some interferences if these mods try to set different log levels. The effective log level depends on the sequence of loading the mods (and thus is predictable but can't be changed). During the control phase each mod has its own instance and thus can set a different log level than the others.

Highlights

From source data

Game versions

Built for Factorio 2.1.

Footprint

Rated a light load on a server.

License

Published under MIT.

log4factorio on Nxeon

From our catalogue
One-click install
Supported on Nxeon Factorio servers. We download it from Factorio Mod Portal, place it, and restart the server.
Server side
Required on the server
Server load
light
Smallest plan we suggest
Factorio — 2 GB (2 GB RAM). This follows our own load rating above, not a benchmark.
Latest build
0.3.0, released 2026-06-23

Run log4factorio on a Factorio server

Pick a server or deploy a new one above; it is installed in one click.

What kind of mod it is

From the catalog
Listed on Factorio Mod Portal as “Mods”

Admin & protection

Permissions, moderation, anti-cheat and land protection for the people running the server.

Runs on your server

From source side support

Factorio Mod Portal lists log4factorio as required on the server. Check its Factorio Mod Portal page to see whether players need it too.

Compatibility

Game
Factorio
Runs on
Serverrequired on the server
Game versions
2.1

Verified at the source

  • ✓Factorio Mod PortalOfficial listing, checked 2026-10-08Open ↗
  • ✓Authorxyzzycgn, as published on Factorio Mod Portal
  • ✓LicenseMITFree

log4factorio, answered

Generated from the mod’s own source data.

Do my players need to install log4factorio?

Factorio Mod Portal lists log4factorio as required on the server. Check its Factorio Mod Portal page to see whether players need it too.

Is it free?

Yes. log4factorio is free to download from Factorio Mod Portal. Its license is MIT.

How do I add it to my Nxeon server?

Use “Add to a server” on this page, or open NxLabs from your dashboard. We install it, restart your server and switch it on.

NxLabs

Run log4factorio on a Factorio server.

Deploy in about a minute from $2.99 a month, then add log4factorio in one click.