About log4factorio
From Factorio Mod Portalfacility 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
- include it with require
local Log = require("__log4factorio__.Log")
- set the desired log level, either
- from configuration
Log.setSeverityFromSettings("testmod1-logLevel")
- or hard coded
Log.setSeverity(Log.WARN)
- 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",
}
},
})
For more details please have a look at https://wiki.factorio.com/Tutorial:Mod_settings#Locale
- 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:
- If you want to log to the factorio-current.log, use
function(m)log(m)endinstead of simplylog. 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 😉.
- 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 dataGame 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 catalogAdmin & protection
Permissions, moderation, anti-cheat and land protection for the people running the server.
Runs on your server
From source side supportFactorio 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
