Log4MC
🟠 Updated over a year agoPreview

🔍 Analysis
- 🏆 #936 of 1745 datapack mods in this game by downloads
📋 About This Mod
<div align="center"> <picture> <source media="(prefers-color-scheme: dark)" alt="light" srcset="https://raw.githubusercontent.com/Z0rillac/log4mc/refs/heads/main/docs/banner_dark.svg" width="400px"> <img alt="light" src="https://raw.githubusercontent.com/Z0rillac/log4mc/refs/heads/main/docs/banner_light.svg" width="400px"> </picture> </div> # Log4MC Log4MC is logger for datapacks. It is an attempt to match the standard logging APIs of other programming languages. It is based on (https://github.com/MulverineX/mcfunction-logger), but adds practical features and a simplified syntax. > ⚠ Caution > It is not recommended to include Log4MC as a module in your datapack, or to distribute your datapack with Log4MC, as this is not done for a production version, but only when creating your datapack. > Furthermore, the end-user should have the choice of using the logger he wants, and if he wants to use one. Indeed, your datapack will still work without Log4MC, even if the logging functions are still present in your code. Calling these functions without any logger responding is EXPECTED behavior. ## Getting Started Logging with Log4MC is pretty simple. At the start of your tick or load file, call `#tick_logger` or `#load_logger` and specify a namespace. You can then use the 6 logging functions, corresponding to the six severity levels : `#trace`, `#debug`, `#info`, `#warn`, `#error`, `#fatal`. *The choice of placing these functions under the default namespace is explained (https://github.com/Z0rillac/log4mc/blob/main/Syntax.md).* ```mcfunction #load.mcfunction function #load_logger {namespace:"mypack"} function #trace {m:"this is a trace"} function #debug {m:"this is a debug"} function #info {m:"this is an info"} function #warn {m:"this is a warn"} function #error {m:"this is an error"} function #fatal {m:"this is a fatal error"} ``` ```mcfunction #tick.mcfunction function #tick_logger {namespace:"mypack"} function #trace {m:"tick"} ``` The logic behind this is that if you register your namespace at the beginning of your tick file or your load file, it's possible to link your logs to your namespace and to the moment of logging. In addition, the severity level can be used to filter and display only relevant logs. In the default configuration, the console severity level is `INFO`. In this case, with the previous example, the console will display this : ``` ... @@@ : this is an info ... @@@ : this is a warn ... @@@ : this is an error ... @@@ : this is a fatal error ``` But if the console's severity level was set to `TRACE`, this would be displayed : ``` ... @@@ : this is a trace ... @@@ : this is a debug ... @@@ : this is an info ... @@@ : this is a warn ... @@@ : this is an error ... @@@ : this is a fatal error ... @@@ : tick ... @@@ : tick ... @@@ : tick ... @@@ : tick ... ... ``` `@@@` indicates that the message displayed in the console is a message from a datapack. The first block corresponds to the moment : - The first letter `L` or `T` indicates whether the message was sent at load or at tick - The number that follows is the gametime (in tick) The second block corresponds to the source of the message : - `mypack` is the namespace of the datapack that produced the log - `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL` is the severity You can change the console's severity level as follows : ``` scoreboard players operation console_level log4mc.main = #off log4mc.enum scoreboard players operation console_level log4mc.main = #trace log4mc.enum ... scoreboard players operation console_level log4mc.main = #fatal log4mc.enum scoreboard players operation console_level log4mc.main = #all log4mc.enum ``` ## Features - Severity logging - Logs formatting - Logs dumping
# Log4MC Log4MC is logger for datapacks. It is an attempt to match the standard logging APIs of other programming languages. It is based on (https://github.com/MulverineX/mcfunction-logger), but adds practical features and a simplified syntax.
> ⚠ Caution > It is not recommended to include Log4MC as a module in your datapack, or to distribute your datapack with Log4MC, as this is not done for a production version, but only when creating your datapack. > Furthermore, the end-user should have the choice of using the logger he wants, and if he wants to use one. Indeed, your datapack will still work without Log4MC, even if the logging functions are still present in your code. Calling these functions without any logger responding is EXPECTED behavior.
## Getting Started
Logging with Log4MC is pretty simple. At the start of your tick or load file, call `#tick_logger` or `#load_logger` and specify a namespace. You can then use the 6 logging functions, corresponding to the six severity levels : `#trace`, `#debug`, `#info`, `#warn`, `#error`, `#fatal`. *The choice of placing these functions under the default namespace is explained (https://github.com/Z0rillac/log4mc/blob/main/Syntax.md).* ```mcfunction #load.mcfunction function #load_logger {namespace:"mypack"}
function #trace {m:"this is a trace"} function #debug {m:"this is a debug"} function #info {m:"this is an info"} function #warn {m:"this is a warn"} function #error {m:"this is an error"} function #fatal {m:"this is a fatal error"} ```
```mcfunction #tick.mcfunction function #tick_logger {namespace:"mypack"}
function #trace {m:"tick"} ```
The logic behind this is that if you register your namespace at the beginning of your tick file or your load file, it's possible to link your logs to your namespace and to the moment of logging. In addition, the severity level can be used to filter and display only relevant logs. In the default configuration, the console severity level is `INFO`. In this case, with the previous example, the console will display this : ``` ... @@@ : this is an info ... @@@ : this is a warn ... @@@ : this is an error ... @@@ : this is a fatal error ``` But if the console's severity level was set to `TRACE`, this would be displayed : ``` ... @@@ : this is a trace ... @@@ : this is a debug ... @@@ : this is an info ... @@@ : this is a warn ... @@@ : this is an error ... @@@ : this is a fatal error ... @@@ : tick ... @@@ : tick ... @@@ : tick ... @@@ : tick ... ... ```
`@@@` indicates that the message displayed in the console is a message from a datapack.
The first block corresponds to the moment : - The first letter `L` or `T` indicates whether the message was sent at load or at tick - The number that follows is the gametime (in tick)
The second block corresponds to the source of the message : - `mypack` is the namespace of the datapack that produced the log - `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL` is the severity
You can change the console's severity level as follows : ``` scoreboard players operation console_level log4mc.main = #off log4mc.enum scoreboard players operation console_level log4mc.main = #trace log4mc.enum ... scoreboard players operation console_level log4mc.main = #fatal log4mc.enum scoreboard players operation console_level log4mc.main = #all log4mc.enum ``` ## Features
- Severity logging
- - Logs formatting
- - Logs dumping
📊 Mod Details
- Game
- Minecraft Data Packs
- Author
- Zorillac
- Version
- 1
- Downloads
- 30
- Endorsements
- 0
- Category
- datapack
- Created
- 1/23/2025
- Updated
- 5/1/2025
- Game Versions
- 1.21.5
- Tags
- library, management
🔧 How to Install Minecraft Data Packs Mods
Download from Modrinth. Use Prism Launcher or drop into your mods folder.
📖 Full step-by-step install guide for Minecraft Data Packs →
Visit the official mod page for specific installation instructions for this mod.
🎮 Need cheat codes or console commands? Check ur gaming wiki for Minecraft Data Packs commands, item IDs, and more.
❓ Frequently Asked Questions
Which Minecraft Data Packs versions does Log4MC support?
The author lists 1.21.5. Other versions may work but are untested by the author.
What is the latest version of Log4MC?
Version 1, published 2025-05-01 with 30 downloads recorded at the source.
Keep browsing — more Minecraft Data Packs mods await