-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjusting logging levels - log4j2.xml #648
Comments
For others who arrive here from searches: I managed to get something working by
<?xml version="1.0" encoding="UTF-8"?>
<Configuration name="Dev">
<Loggers>
<Logger name="com.example" level="trace" additivity="false">
<AppenderRef ref="DebugFile" level="${sys:fabric.log.debug.level:-debug}" />
<AppenderRef ref="SysOut" />
<AppenderRef ref="LatestFile" level="${sys:fabric.log.level:-info}" />
<AppenderRef ref="ServerGuiConsole" />
</Logger>
</Loggers>
</Configuration> (Replace loom {
log4jConfigs.from(file("log4j-dev.xml"))
} |
This doesn't work for me and i can't find a way to set my log level anywhere on the web. Maybe I'm just stupid but i think logging is a huge hole in the fabric docs. |
If someone finds this issue like I did, here's a configuration that worked for me <?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG" packages="com.example">
<Loggers>
<Logger name="com.example.ExampleMod" level="debug">
<AppenderRef ref="SysOut"/>
<AppenderRef ref="ServerGuiConsole"/>
</Logger>
</Loggers>
</Configuration> Inside of the import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ExampleMod implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger(ExampleMod.class);
@Override
public void onInitialize() {
LOGGER.debug("Hello DEBUG");
// ... |
Hi, could you please point out that how to make the program use this custom log4j config file? Like, where do you put this file? I tried to replace loom's log4j file with loom And adding Sincerely thanks. |
The file could be wherever you want it to, though in normal applications it's usually put in loom {
log4jConfigs.from file("src/dev/resources/log4j.xml")
} I can see in
|
Thanks again! For others who arrive here, please check this commit as reference. That mod is using architectury fork of loom for supporting more mod platforms, so as you can see we have both |
Closing this issue as I dont think there is anything else for loom to do. |
For all Eclipse users: If you can't see the path that you set in the build.grade, run the |
Currently it is difficult to setup per-package logging levels during mod development. Since fabric/loom rely on log4j it should be a simple matter of editing the log4j2.xml file or rely or adding a log4j2.xml file that would get merged automatically by functionality already in loom.
As discussed with modmuss50, there are two possible solutions: (1) To improve the wiki documentation so that it would become trivial to do. And/or (2) to add a configuration item in fabric.mod.json to indicate where to place the supplemental log4j2.xml file.
With something like that it would be very easy to create a log4j2.xml like this:
The text was updated successfully, but these errors were encountered: