Jump to content

How to set up my logger?


BrainStone

Recommended Posts

Hello.

I am currently trying to set up logger. Meaning I want to determine which logging levels should be logged an which ones not. How can i do this?

 

(I didn't find any tutorials)

 

This is the code I'm currently using:

 

		// Somewhere in my preInit
	logger = event.getModLog();

	//Checks if mod is in debug mode (log all)
	if (BrainStone.debug) {
		logger.setLevel(Level.ALL);
	//Checks if mod is a release (log less)
	} else if (BrainStone.release) {
		logger.setLevel(Level.INFO);
	//Default (log some)
	} else {
		logger.setLevel(Level.FINE);
	}
	// Some other code

 

This does not work!

And I'm pretty sure why this does not work.

 

Here an extract from the documentation of the FMLPreInitializationEvent.getModLog method:

Configurations can be applied through the config/logging.properties file, specifying logging levels for your ModID. Use this!

 

So how do I set everything up?

Link to comment
Share on other sites

If you just want something simple, just use System.out.printf("message here %n") but that doesn't work with logging levels as far as I know

 

Are you kidding me? ???

 

 

That does not work. I'm using this code:

 

		// Somewhere in my preInit
	logger = event.getModLog();

	//Checks if mod is in debug mode (log all)
	if (BrainStone.debug) {
		logger.setLevel(Level.ALL);
	//Checks if mod is a release (log less)
	} else if (BrainStone.release) {
		logger.setLevel(Level.INFO);
	//Default (log some)
	} else {
		logger.setLevel(Level.FINE);
	}
	// Some other code

 

And I'm pretty sure why this does not work.

 

Here an extract from the documentation of the FMLPreInitializationEvent.getModLog method:

Configurations can be applied through the config/logging.properties file, specifying logging levels for your ModID. Use this!

 

So how do I set everything up?

Link to comment
Share on other sites

I figured this out last night in my own code. The console log defaults to INFO level, and is not affected by setting log levels on the FMLLog. However, if you go check your Forge log files, I think you'll find all those missing FINEST/FINER/FINE messages being written out.

 

The console log cannot be changed via the "logging.properties" file; it is hard-coded in the initialization to "INFO", and the console logger object is private and cannot be accessed.

 

I decided for my own project a logging.properties file wasn't necessary because the FMLLog can be set internally, so I did not retain one.

 

However, if you want one, it goes in the top level of your config directory.  You can find an example one the one used by your JRE, with comments, in the jre/lib directory of your JDK. (In my case, that would be C:\Program Files\Java\jdk1.7.0_25\jre\lib\logging.properties). Don't tamper with that one, just use it as an example.  The general use of

it is discussed in the Java LogManager class documentation at http://docs.oracle.com/javase/7/docs/api/java/util/logging/LogManager.html.

 

Here's the important contents:

 

# Default global logging level
.level= INFO

 

would set the FMLlog and all child logs to default level of INFO, unless otherwise specified.

You can either specify otherwise programmatically, or by using the name of the logger (as set by "getLog()")

+ '.level'; e.g.

 

ForgeModLoader.level=ALL 

 

should set the FML file log to level.ALL, for example.

Link to comment
Share on other sites

I figured this out last night in my own code. The console log defaults to INFO level, and is not affected by setting log levels on the FMLLog. However, if you go check your Forge log files, I think you'll find all those missing FINEST/FINER/FINE messages being written out.

 

The console log cannot be changed via the "logging.properties" file; it is hard-coded in the initialization to "INFO", and the console logger object is private and cannot be accessed.

 

I decided for my own project a logging.properties file wasn't necessary because the FMLLog can be set internally, so I did not retain one.

 

However, if you want one, it goes in the top level of your config directory.  You can find an example one the one used by your JRE, with comments, in the jre/lib directory of your JDK. (In my case, that would be C:\Program Files\Java\jdk1.7.0_25\jre\lib\logging.properties). Don't tamper with that one, just use it as an example.  The general use of

it is discussed in the Java LogManager class documentation at http://docs.oracle.com/javase/7/docs/api/java/util/logging/LogManager.html.

 

Here's the important contents:

 

# Default global logging level
.level= INFO

 

would set the FMLlog and all child logs to default level of INFO, unless otherwise specified.

You can either specify otherwise programmatically, or by using the name of the logger (as set by "getLog()")

+ '.level'; e.g.

 

ForgeModLoader.level=ALL 

 

should set the FML file log to level.ALL, for example.

 

Thank you. This helped me! But there's still a problem. When I use this logging.properties file:

.level=ALL
BrainStoneMod.level=ALL
ForgeModLoader.level=ALL

(BrainStoneMod is my ModID) then still the fine/finer/finest levels are not displayed! I put it in mcp/jars/config. (That's the place where all other configs are located and in the beginning it says that ForgeModLoader logging level is set to ALL.)

 

What have I not seen? Or what could I do to fix this?

Link to comment
Share on other sites

Are you looking at the console window in Eclipse for your messages, or at the '\forge\mcp\jars\ForgeModLoader-client-0.log" on your hard drive?  Like I said, you can't change the logging level of the console window; but if they are not showing up in the "ForgeModLoader-client-0.log" log file, something is definitely wrong.

 

 

Link to comment
Share on other sites

Could you tell me where I can find the member or even better where I can the spot where the level.INFO is hard coded?

I'm thinking about using reflection to manipulate the logger during runtime. Which should make it possible to set the console logging Level for my logger to Level.ALL.

 

(Is ist possible to only do this to my logger?)

Link to comment
Share on other sites

Could you tell me where I can find the member or even better where I can the spot where the level.INFO is hard coded?

I'm thinking about using reflection to manipulate the logger during runtime. Which should make it possible to set the console logging Level for my logger to Level.ALL.

 

(Is ist possible to only do this to my logger?)

 

That would be insanely retarded to do :P

I mean, changing a part of the java standard lib, I like to believe it was made as it was for good reasons, and at your current level you probably don't understand them yet!

 

I don't know what the F you are trying to do or why, but I can promise you that if you feel you must resort to manipulating the standard libraries, you are doing something very very VERY wrong. I'd suggest you re-think your implementation plan and WHY you need to do it, there's probably a different way to accomplish whatever you really want to do..

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Ok. To clear things up:

 

I have set up my mod and everything. And I have messages to log to the console. The messages have different levels off logging. (Ranging from SEVERE to FINEST) And depending on some flags I want them either to appear or not. For several reasons I cannot just use the output (Forge-client-log-0.log) for example because I need these messages to debug my code.

Now changing the logging levels of these messages isn't a good solution. I'd have to find the messages (might be pretty hard because there are many) change the logging level and after I'm done I have to change them back. Isn't there another solution to this?

 

I have also written a logger wrapper class: (It's very large)

 

 

Link to the class: https://github.com/BrainStone/brainstone/blob/master/brainstonemod/templates/BSP.java

 

package brainstonemod.templates;

import java.util.logging.Level;
import java.util.logging.Logger;

import brainstonemod.BrainStone;

/**
* <center><b><u>B</u>rain<u>S</u>tone<u>P</u>rinter</b></center><br>
* This class is the printer class for the BrainStoneMod. It contains a lot of
* static final printing methods, that will print the given object under the
* right conditions. Exceptions will be thrown here as well.
* 
* @author Yannick Schinko (alias The_BrainStone)
* @version 2.0.0
* @category Print
*/
public abstract class BSP {
/**
 * A error message addon that is very big, asks the user to send the error
 * log to the mod developer, and contains the email address
 */
public static final String errorMessageAddon = "\n==================================================\n"
		+ "==================================================\n"
		+ "   There occured an error in the BrainStoneMod!   \n"
		+ "   Please send the error log to the developer.    \n"
		+ "   This is important if you want the error to be  \n"
		+ "  fixed. To send the log to me, just send a email \n"
		+ "         with the file of the error log to        \n"
		+ "                [email protected]               \n\n"
		+ "              Thank you for your help!            \n"
		+ "==================================================\n"
		+ "==================================================\n";

/**
 * This is the logger for the BSM. Will be initialized in the BrainStone
 * class
 */
private static Logger logger;

/**
 * <b>A</b>dd<b>N</b>ew<b>L</b>ine<b>I</b>f<b>N</b>ecessary<br>
 * This function adds a new line in front of a string if necessary.
 * 
 * @param str
 *            String to be processed
 * @return If the String is no empty, a new line will be added in front of
 *         str
 */
private static final String ANLIN(String str) {
	return (str.isEmpty()) ? str : "\n" + str;
}

/**
 * Logs all Objects to the console with the normal CONFIG level
 * 
 * @param obj
 *            the objects to be logged
 * @return Return whether the log was logged or not
 * @see public static final boolean print(Level.CONFIG, Object... obj)
 */
public static final boolean config(Object... obj) {
	for (final Object log : obj) {
		logger.config(log.toString());
	}

	return logger.isLoggable(Level.CONFIG);
}

/**
 * This logs an error to the console with the CONFIG level and appends the
 * errorMessageAddon
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 * @see printException(Level.CONFIG, Exception ex)
 * @see printException(Exception ex)
 */
public static final boolean configException(Exception ex) {
	return configException(ex, "");
}

/**
 * This logs an error to the console with the CONFIG level and appends the
 * errorMessageAddon and an additional message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message appended to the standard error message addon
 * @return Return whether the log was logged or not
 * @see printException(Level.CONFIG, Exception ex, String additionalMessage)
 * @see printException(Exception ex, String additionalMessage)
 */
public static final boolean configException(Exception ex,
		String additionalMessage) {
	logger.log(Level.CONFIG, errorMessageAddon + ANLIN(additionalMessage),
			ex);

	return logger.isLoggable(Level.CONFIG);
}

/**
 * This logs an error to the console with the CONFIG level
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 *         printException_noAddon(Level.CONFIG, Exception ex)
 * @see printException_noAddon(Exception ex)
 */
public static final boolean configException_noAddon(Exception ex) {
	return configException_noAddon(ex, "");
}

/**
 * This logs an error to the console with the CONFIG level and an additional
 * message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message put in front of the error log
 * @return Return whether the log was logged or not
 * @see printException_noAddon(Level.CONFIG, Exception ex, String
 *      additionalMessage)
 * @see printException_noAddon(Exception ex, String additionalMessage)
 */
public static final boolean configException_noAddon(Exception ex,
		String additionalMessage) {
	logger.log(Level.CONFIG, additionalMessage, ex);

	return logger.isLoggable(Level.CONFIG);
}

/**
 * Logs all Objects to the console with the normal FINE level
 * 
 * @param obj
 *            the objects to be logged
 * @return Return whether the log was logged or not
 * @see public static final boolean print(Level.FINE, Object... obj)
 */
public static final boolean fine(Object... obj) {
	for (final Object log : obj) {
		logger.fine(log.toString());
	}

	return logger.isLoggable(Level.FINE);
}

/**
 * This logs an error to the console with the FINE level and appends the
 * errorMessageAddon
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 * @see printException(Level.FINE, Exception ex)
 * @see printException(Exception ex)
 */
public static final boolean fineException(Exception ex) {
	return fineException(ex, "");
}

/**
 * This logs an error to the console with the FINE level and appends the
 * errorMessageAddon and an additional message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message appended to the standard error message addon
 * @return Return whether the log was logged or not
 * @see printException(Level.FINE, Exception ex, String additionalMessage)
 * @see printException(Exception ex, String additionalMessage)
 */
public static final boolean fineException(Exception ex,
		String additionalMessage) {
	logger.log(Level.FINE, errorMessageAddon + ANLIN(additionalMessage), ex);

	return logger.isLoggable(Level.FINE);
}

/**
 * This logs an error to the console with the FINE level
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 *         printException_noAddon(Level.FINE, Exception ex)
 * @see printException_noAddon(Exception ex)
 */
public static final boolean fineException_noAddon(Exception ex) {
	return fineException_noAddon(ex, "");
}

/**
 * This logs an error to the console with the FINE level and an additional
 * message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message put in front of the error log
 * @return Return whether the log was logged or not
 * @see printException_noAddon(Level.FINE, Exception ex, String
 *      additionalMessage)
 * @see printException_noAddon(Exception ex, String additionalMessage)
 */
public static final boolean fineException_noAddon(Exception ex,
		String additionalMessage) {
	logger.log(Level.FINE, additionalMessage, ex);

	return logger.isLoggable(Level.FINE);
}

/**
 * Logs all Objects to the console with the normal FINER level
 * 
 * @param obj
 *            the objects to be logged
 * @return Return whether the log was logged or not
 * @see public static final boolean print(Level.FINER, Object... obj)
 */
public static final boolean finer(Object... obj) {
	for (final Object log : obj) {
		logger.finer(log.toString());
	}

	return logger.isLoggable(Level.FINER);
}

/**
 * This logs an error to the console with the FINER level and appends the
 * errorMessageAddon
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 * @see printException(Level.FINER, Exception ex)
 * @see printException(Exception ex)
 */
public static final boolean finerException(Exception ex) {
	return finerException(ex, "");
}

/**
 * This logs an error to the console with the FINER level and appends the
 * errorMessageAddon and an additional message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message appended to the standard error message addon
 * @return Return whether the log was logged or not
 * @see printException(Level.FINER, Exception ex, String additionalMessage)
 * @see printException(Exception ex, String additionalMessage)
 */
public static final boolean finerException(Exception ex,
		String additionalMessage) {
	logger.log(Level.FINER, errorMessageAddon + ANLIN(additionalMessage),
			ex);

	return logger.isLoggable(Level.FINER);
}

/**
 * This logs an error to the console with the FINER level
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 *         printException_noAddon(Level.FINER, Exception ex)
 * @see printException_noAddon(Exception ex)
 */
public static final boolean finerException_noAddon(Exception ex) {
	return finerException_noAddon(ex, "");
}

/**
 * This logs an error to the console with the FINER level and an additional
 * message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message put in front of the error log
 * @return Return whether the log was logged or not
 * @see printException_noAddon(Level.FINER, Exception ex, String
 *      additionalMessage)
 * @see printException_noAddon(Exception ex, String additionalMessage)
 */
public static final boolean finerException_noAddon(Exception ex,
		String additionalMessage) {
	logger.log(Level.FINER, additionalMessage, ex);

	return logger.isLoggable(Level.FINER);
}

/**
 * Logs all Objects to the console with the normal FINEST level
 * 
 * @param obj
 *            the objects to be logged
 * @return Return whether the log was logged or not
 * @see public static final boolean print(Level.FINEST, Object... obj)
 */
public static final boolean finest(Object... obj) {
	for (final Object log : obj) {
		logger.finest(log.toString());
	}

	return logger.isLoggable(Level.FINEST);
}

/**
 * This logs an error to the console with the FINEST level and appends the
 * errorMessageAddon
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 * @see printException(Level.FINEST, Exception ex)
 * @see printException(Exception ex)
 */
public static final boolean finestException(Exception ex) {
	return finestException(ex, "");
}

/**
 * This logs an error to the console with the FINEST level and appends the
 * errorMessageAddon and an additional message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message appended to the standard error message addon
 * @return Return whether the log was logged or not
 * @see printException(Level.FINEST, Exception ex, String additionalMessage)
 * @see printException(Exception ex, String additionalMessage)
 */
public static final boolean finestException(Exception ex,
		String additionalMessage) {
	logger.log(Level.FINEST, errorMessageAddon + ANLIN(additionalMessage),
			ex);

	return logger.isLoggable(Level.FINEST);
}

/**
 * This logs an error to the console with the FINEST level
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 *         printException_noAddon(Level.FINEST, Exception ex)
 * @see printException_noAddon(Exception ex)
 */
public static final boolean finestException_noAddon(Exception ex) {
	return finestException_noAddon(ex, "");
}

/**
 * This logs an error to the console with the FINEST level and an additional
 * message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message put in front of the error log
 * @return Return whether the log was logged or not
 * @see printException_noAddon(Level.FINEST, Exception ex, String
 *      additionalMessage)
 * @see printException_noAddon(Exception ex, String additionalMessage)
 */
public static final boolean finestException_noAddon(Exception ex,
		String additionalMessage) {
	logger.log(Level.FINEST, additionalMessage, ex);

	return logger.isLoggable(Level.FINEST);
}

/**
 * Logs all Objects to the console with the normal INFO level
 * 
 * @param obj
 *            the objects to be logged
 * @return Return whether the log was logged or not
 * @see public static final boolean print(Object... obj)
 * @see public static final boolean print(Level.INFO, Object... obj)
 */
public static final boolean info(Object... obj) {
	for (final Object log : obj) {
		logger.info(log.toString());
	}

	return logger.isLoggable(Level.INFO);
}

/**
 * This logs an error to the console with the normal INFO level and appends
 * the errorMessageAddon
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 * @see printException(Level.INFO, Exception ex)
 * @see printException(Exception ex)
 */
public static final boolean infoException(Exception ex) {
	return infoException(ex, "");
}

/**
 * This logs an error to the console with the normal INFO level and appends
 * the errorMessageAddon and an additional message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message appended to the standard error message addon
 * @return Return whether the log was logged or not
 * @see printException(Level.INFO, Exception ex, String additionalMessage)
 * @see printException(Exception ex, String additionalMessage)
 */
public static final boolean infoException(Exception ex,
		String additionalMessage) {
	logger.log(Level.INFO, errorMessageAddon + ANLIN(additionalMessage), ex);

	return logger.isLoggable(Level.INFO);
}

/**
 * This logs an error to the console with the normal INFO level
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 *         printException_noAddon(Level.INFO, Exception ex)
 * @see printException_noAddon(Exception ex)
 */
public static final boolean infoException_noAddon(Exception ex) {
	return infoException_noAddon(ex, "");
}

/**
 * This logs an error to the console with the normal INFO level and an
 * additional message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message put in front of the error log
 * @return Return whether the log was logged or not
 * @see printException_noAddon(Level.INFO, Exception ex, String
 *      additionalMessage)
 * @see printException_noAddon(Exception ex, String additionalMessage)
 */
public static final boolean infoException_noAddon(Exception ex,
		String additionalMessage) {
	logger.log(Level.INFO, additionalMessage, ex);

	return logger.isLoggable(Level.INFO);
}

/**
 * Logs all Objects to the console with the level to be logged
 * 
 * @param level
 *            the level the objects will be logged
 * @param obj
 *            the objects to be logged
 * @return Return whether the log was logged or not
 */
public static final boolean print(Level level, Object... obj) {
	for (final Object log : obj) {
		logger.log(level, log.toString());
	}

	return logger.isLoggable(level);
}

/**
 * Logs all Objects to the console with the normal INFO level
 * 
 * @param obj
 *            the objects to be logged
 * @return Return whether the log was logged or not
 * @see public static final boolean info(Object... obj)
 * @see public static final boolean print(Level.INFO, Object... obj)
 */
public static final boolean print(Object... obj) {
	for (final Object log : obj) {
		logger.info(log.toString());
	}

	return logger.isLoggable(Level.INFO);
}

/**
 * This logs an error to the console with the normal INFO level and appends
 * the errorMessageAddon
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 * @see printException(Level.INFO, Exception ex)
 * @see infoException(Exception ex)
 */
public static final boolean printException(Exception ex) {
	return printException(ex, "");
}

/**
 * This logs an error to the console with the normal INFO level and appends
 * the errorMessageAddon and an additional message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message appended to the standard error message addon
 * @return Return whether the log was logged or not
 * @see printException(Level.INFO, Exception ex, String additionalMessage)
 * @see infoException(Exception ex, String additionalMessage)
 */
public static final boolean printException(Exception ex,
		String additionalMessage) {
	logger.log(Level.INFO, errorMessageAddon + ANLIN(additionalMessage), ex);

	return logger.isLoggable(Level.INFO);
}

/**
 * This logs an error to the console with the level to be logged
 * 
 * @param level
 *            the level the objects will be logged
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 */
public static final boolean printException(Level level, Exception ex) {
	return printException(level, ex, "");
}

/**
 * This logs an error to the console with an additional message and the
 * level to be logged
 * 
 * @param level
 *            the level the objects will be logged
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message appended to the standard error message addon
 * @return Return whether the log was logged or not
 */
public static final boolean printException(Level level, Exception ex,
		String additionalMessage) {
	logger.log(level, errorMessageAddon + ANLIN(additionalMessage), ex);

	return logger.isLoggable(level);
}

/**
 * This logs an error to the console with the normal INFO level
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 *         printException_noAddon(Level.INFO, Exception ex)
 * @see infoException_noAddon(Exception ex)
 */
public static final boolean printException_noAddon(Exception ex) {
	return printException_noAddon(ex, "");
}

/**
 * This logs an error to the console with the normal INFO level and an
 * additional message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message put in front of the error log
 * @return Return whether the log was logged or not
 * @see printException_noAddon(Level.INFO, Exception ex, String
 *      additionalMessage)
 * @see infoException_noAddon(Exception ex, String additionalMessage)
 */
public static final boolean printException_noAddon(Exception ex,
		String additionalMessage) {
	logger.log(Level.INFO, additionalMessage, ex);

	return logger.isLoggable(Level.INFO);
}

/**
 * This logs an error to the console with the level to be logged
 * 
 * @param level
 *            the level the objects will be logged
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 */
public static final boolean printException_noAddon(Level level, Exception ex) {
	return printException_noAddon(level, ex, "");
}

/**
 * This logs an error to the console with an additional message and the
 * level to be logged
 * 
 * @param level
 *            the level the objects will be logged
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message put in front of the error log
 * @return Return whether the log was logged or not
 */
public static final boolean printException_noAddon(Level level,
		Exception ex, String additionalMessage) {
	logger.log(level, additionalMessage, ex);

	return logger.isLoggable(level);
}

/**
 * Sets up the logger and also sets up the corresponding filter
 * 
 * @param logger
 *            - the logger for this class
 */
public static void setUpLogger(Logger logger) {
	BSP.logger = logger;

	if (BrainStone.debug) {
		BSP.logger.setLevel(Level.ALL);
	} else if (BrainStone.release) {
		BSP.logger.setLevel(Level.INFO);
	} else {
		BSP.logger.setLevel(Level.FINE);
	}
}

/**
 * Logs all Objects to the console with the normal SEVERE level
 * 
 * @param obj
 *            the objects to be logged
 * @return Return whether the log was logged or not
 * @see public static final boolean print(Level.SEVERE, Object... obj)
 */
public static final boolean severe(Object... obj) {
	for (final Object log : obj) {
		logger.severe(log.toString());
	}

	return logger.isLoggable(Level.SEVERE);
}

/**
 * This logs an error to the console with the SEVERE level and appends the
 * errorMessageAddon
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 * @see printException(Level.SEVERE, Exception ex)
 * @see printException(Exception ex)
 */
public static final boolean severeException(Exception ex) {
	return severeException(ex, "");
}

/**
 * This logs an error to the console with the SEVERE level and appends the
 * errorMessageAddon and an additional message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message appended to the standard error message addon
 * @return Return whether the log was logged or not
 * @see printException(Level.SEVERE, Exception ex, String additionalMessage)
 * @see printException(Exception ex, String additionalMessage)
 */
public static final boolean severeException(Exception ex,
		String additionalMessage) {
	logger.log(Level.SEVERE, errorMessageAddon + ANLIN(additionalMessage),
			ex);

	return logger.isLoggable(Level.SEVERE);
}

/**
 * This logs an error to the console with the SEVERE level
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 *         printException_noAddon(Level.SEVERE, Exception ex)
 * @see printException_noAddon(Exception ex)
 */
public static final boolean severeException_noAddon(Exception ex) {
	return severeException_noAddon(ex, "");
}

/**
 * This logs an error to the console with the SEVERE level and an additional
 * message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message put in front of the error log
 * @return Return whether the log was logged or not
 * @see printException_noAddon(Level.SEVERE, Exception ex, String
 *      additionalMessage)
 * @see printException_noAddon(Exception ex, String additionalMessage)
 */
public static final boolean severeException_noAddon(Exception ex,
		String additionalMessage) {
	logger.log(Level.SEVERE, additionalMessage, ex);

	return logger.isLoggable(Level.SEVERE);
}

/**
 * Throws a ArithmeticException with the error message addon
 */
public static final void throwArithmeticException() {
	throwArithmeticException("");
}

/**
 * Throws a ArithmeticException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwArithmeticException(String additionalMessage) {
	throw new ArithmeticException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a ArrayIndexOutOfBoundsException with the error message addon
 */
public static final void throwArrayIndexOutOfBoundsException() {
	throwArrayIndexOutOfBoundsException("");
}

/**
 * Throws a ArrayIndexOutOfBoundsException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwArrayIndexOutOfBoundsException(
		String additionalMessage) {
	throw new ArrayIndexOutOfBoundsException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a ArrayStoreException with the error message addon
 */
public static final void throwArrayStoreException() {
	throwArrayStoreException("");
}

/**
 * Throws a ArrayStoreException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwArrayStoreException(String additionalMessage) {
	throw new ArrayStoreException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a ClassCastException with the error message addon
 */
public static final void throwClassCastException() {
	throwClassCastException("");
}

/**
 * Throws a ClassCastException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwClassCastException(String additionalMessage) {
	throw new ClassCastException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a ClassNotFoundException with the error message addon
 * 
 * @throws ClassNotFoundException
 */
public static final void throwClassNotFoundException()
		throws ClassNotFoundException {
	throwClassNotFoundException("");
}

/**
 * Throws a ClassNotFoundException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 * @throws ClassNotFoundException
 */
public static final void throwClassNotFoundException(
		String additionalMessage) throws ClassNotFoundException {
	throw new ClassNotFoundException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a CloneNotSupportedException with the error message addon
 * 
 * @throws CloneNotSupportedException
 */
public static final void throwCloneNotSupportedException()
		throws CloneNotSupportedException {
	throwCloneNotSupportedException("");
}

/**
 * Throws a CloneNotSupportedException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 * @throws CloneNotSupportedException
 */
public static final void throwCloneNotSupportedException(
		String additionalMessage) throws CloneNotSupportedException {
	throw new CloneNotSupportedException(errorMessageAddon
			+ ((additionalMessage.equals("")) ? "" : "\n"
					+ additionalMessage));
}

/**
 * Throws a Exception with the error message addon
 * 
 * @throws Exception
 */
public static final void throwException() throws Exception {
	throwException("");
}

/**
 * Throws a exception with the error message addon. This is for all
 * <b><u>non-RuntimeExceptions</u></b>
 * 
 * @param exception
 *            the exception to throw
 * @throws E
 *             the exception type
 */
public static final <E extends Throwable> void throwException(E exception)
		throws E {
	throwException(exception, "");
}

/**
 * Throws a exception with the error message addon. This is for all
 * <b><u>RuntimeExceptions</u></b>
 * 
 * @param exception
 *            the exception to throw
 */
public static final <E extends RuntimeException> void throwException(
		E exception) {
	throwException(exception, "");
}

/**
 * Throws a exception with the error message addon and a custom message.
 * This is for all <b><u>non-RuntimeExceptions</u></b>
 * 
 * @param exception
 *            the exception to throw
 * @param additionalMessage
 *            the custom message that will be added
 * @throws E
 *             the exception type
 */
public static final <E extends Throwable> void throwException(E exception,
		String additionalMessage) throws E {
	throw (E) new Throwable("(" + exception.getClass().getName() + ")"
			+ BSP.errorMessageAddon + ANLIN(additionalMessage + "\n")
			+ "\nOriginal message: \"" + exception.getMessage() + "\"\n",
			exception);
}

/**
 * Throws a exception with the error message addon and a custom message.
 * This is for all <b><u>RuntimeExceptions</u></b>
 * 
 * @param exception
 *            the exception to throw
 * @param additionalMessage
 *            the custom message that will be added
 */
public static final <E extends RuntimeException> void throwException(
		E exception, String additionalMessage) {
	throw (E) new RuntimeException("(" + exception.getClass().getName()
			+ ")" + errorMessageAddon + ANLIN(additionalMessage + "\n")
			+ "\nOriginal message: \"" + exception.getMessage() + "\"\n",
			exception);
}

/**
 * Throws a Exception with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 * @throws Exception
 */
public static final void throwException(String additionalMessage)
		throws Exception {
	throw new Exception(errorMessageAddon + ANLIN(additionalMessage));
}

/**
 * Throws a IllegalAccessException with the error message addon
 * 
 * @throws IllegalAccessException
 */
public static final void throwIllegalAccessException()
		throws IllegalAccessException {
	throwIllegalAccessException("");
}

/**
 * Throws a IllegalAccessException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 * @throws IllegalAccessException
 */
public static final void throwIllegalAccessException(
		String additionalMessage) throws IllegalAccessException {
	throw new IllegalAccessException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a IllegalArgumentException with the error message addon
 */
public static final void throwIllegalArgumentException() {
	throwIllegalArgumentException("");
}

/**
 * Throws a IllegalArgumentException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwIllegalArgumentException(
		String additionalMessage) {
	throw new IllegalArgumentException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a IllegalMonitorStateException with the error message addon
 */
public static final void throwIllegalMonitorStateException() {
	throwIllegalMonitorStateException("");
}

/**
 * Throws a IllegalMonitorStateException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwIllegalMonitorStateException(
		String additionalMessage) {
	throw new IllegalMonitorStateException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a IllegalThreadStateException with the error message addon
 */
public static final void throwIllegalThreadStateException() {
	throwIllegalThreadStateException("");
}

/**
 * Throws a IllegalThreadStateException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwIllegalThreadStateException(
		String additionalMessage) {
	throw new IllegalThreadStateException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a IndexOutOfBoundsException with the error message addon
 */
public static final void throwIndexOutOfBoundsException() {
	throwIndexOutOfBoundsException("");
}

/**
 * Throws a IndexOutOfBoundsException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwIndexOutOfBoundsException(
		String additionalMessage) {
	throw new IndexOutOfBoundsException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a InstantiationException with the error message addon
 * 
 * @throws InstantiationException
 */
public static final void throwInstantiationException()
		throws InstantiationException {
	throwInstantiationException("");
}

/**
 * Throws a InstantiationException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 * @throws InstantiationException
 */
public static final void throwInstantiationException(
		String additionalMessage) throws InstantiationException {
	throw new InstantiationException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a InterruptedException with the error message addon
 * 
 * @throws InterruptedException
 */
public static final void throwInterruptedException()
		throws InterruptedException {
	throwInterruptedException("");
}

/**
 * Throws a InterruptedException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 * @throws InterruptedException
 */
public static final void throwInterruptedException(String additionalMessage)
		throws InterruptedException {
	throw new InterruptedException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a NegativeArraySizeException with the error message addon
 */
public static final void throwNegativeArraySizeException() {
	throwNegativeArraySizeException("");
}

/**
 * Throws a NegativeArraySizeException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwNegativeArraySizeException(
		String additionalMessage) {
	throw new NegativeArraySizeException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a NoSuchMethodException with the error message addon
 * 
 * @throws NoSuchMethodException
 */
public static final void throwNoSuchMethodException()
		throws NoSuchMethodException {
	throwNoSuchMethodException("");
}

/**
 * Throws a NoSuchMethodException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 * @throws NoSuchMethodException
 */
public static final void throwNoSuchMethodException(String additionalMessage)
		throws NoSuchMethodException {
	throw new NoSuchMethodException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a NullPointerException with the error message addon
 */
public static final void throwNullPointerException() {
	throwNullPointerException("");
}

/**
 * Throws a NullPointerException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwNullPointerException(String additionalMessage) {
	throw new NullPointerException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a NumberFormatException with the error message addon
 */
public static final void throwNumberFormatException() {
	throwNumberFormatException("");
}

/**
 * Throws a NumberFormatException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwNumberFormatException(String additionalMessage) {
	throw new NumberFormatException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a RuntimeException with the error message addon
 */
public static final void throwRuntimeException() {
	throwRuntimeException("");
}

/**
 * Throws a RuntimeException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwRuntimeException(String additionalMessage) {
	throw new RuntimeException(errorMessageAddon + ANLIN(additionalMessage));
}

/**
 * Throws a SecurityException with the error message addon
 */
public static final void throwSecurityException() {
	throwSecurityException("");
}

/**
 * Throws a SecurityException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwSecurityException(String additionalMessage) {
	throw new SecurityException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a StringIndexOutOfBoundsException with the error message addon
 */
public static final void throwStringIndexOutOfBoundsException() {
	throwStringIndexOutOfBoundsException("");
}

/**
 * Throws a StringIndexOutOfBoundsException with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 */
public static final void throwStringIndexOutOfBoundsException(
		String additionalMessage) {
	throw new StringIndexOutOfBoundsException(errorMessageAddon
			+ ANLIN(additionalMessage));
}

/**
 * Throws a Throwable with the error message addon
 * 
 * @throws Throwable
 */
public static final void throwThrowable() throws Throwable {
	throwThrowable("");
}

/**
 * Throws a Throwable with the error message addon
 * 
 * @param additionalMessage
 *            a additional message added after the addon
 * @throws Throwable
 */
public static final void throwThrowable(String additionalMessage)
		throws Throwable {
	throw new Throwable(errorMessageAddon + ANLIN(additionalMessage));
}

/**
 * Logs all Objects to the console with the normal WARNING level
 * 
 * @param obj
 *            the objects to be logged
 * @return Return whether the log was logged or not
 * @see public static final boolean print(Level.WARNING, Object... obj)
 */
public static final boolean warning(Object... obj) {
	for (final Object log : obj) {
		logger.warning(log.toString());
	}

	return logger.isLoggable(Level.WARNING);
}

/**
 * This logs an error to the console with the WARNING level and appends the
 * errorMessageAddon
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 * @see printException(Level.WARNING, Exception ex)
 * @see printException(Exception ex)
 */
public static final boolean warningException(Exception ex) {
	return warningException(ex, "");
}

/**
 * This logs an error to the console with the WARNING level and appends the
 * errorMessageAddon and an additional message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message appended to the standard error message addon
 * @return Return whether the log was logged or not
 * @see printException(Level.WARNING, Exception ex, String
 *      additionalMessage)
 * @see printException(Exception ex, String additionalMessage)
 */
public static final boolean warningException(Exception ex,
		String additionalMessage) {
	logger.log(Level.WARNING, errorMessageAddon + ANLIN(additionalMessage),
			ex);

	return logger.isLoggable(Level.WARNING);
}

/**
 * This logs an error to the console with the WARNING level
 * 
 * @param ex
 *            the exception to be logged
 * @return Return whether the log was logged or not
 *         printException_noAddon(Level.WARNING, Exception ex)
 * @see printException_noAddon(Exception ex)
 */
public static final boolean warningException_noAddon(Exception ex) {
	return warningException_noAddon(ex, "");
}

/**
 * This logs an error to the console with the WARNING level and an
 * additional message
 * 
 * @param ex
 *            the exception to be logged
 * @param additionalMessage
 *            a message put in front of the error log
 * @return Return whether the log was logged or not
 * @see printException_noAddon(Level.WARNING, Exception ex, String
 *      additionalMessage)
 * @see printException_noAddon(Exception ex, String additionalMessage)
 */
public static final boolean warningException_noAddon(Exception ex,
		String additionalMessage) {
	logger.log(Level.WARNING, additionalMessage, ex);

	return logger.isLoggable(Level.WARNING);
}
}

 

Link to comment
Share on other sites

why cant you just use System.out.println like 99% of us ? this seems like a lot of effort to see

[sTDOUT][MyMod] penis 1

[sTDOUT][MyMod] penis 2

[sTDOUT][MyMod] penis 3

[sTDOUT][MyMod] penis 4

[sTDOUT][MyMod] penis 5

 

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

why cant you just use System.out.println like 99% of us ? this seems like a lot of effort to see

[sTDOUT][MyMod] penis 1

[sTDOUT][MyMod] penis 2

[sTDOUT][MyMod] penis 3

[sTDOUT][MyMod] penis 4

[sTDOUT][MyMod] penis 5

 

You obviously haven't understood the use of a logger. It basically rates messages. And also can disable them based on their rating.

Link to comment
Share on other sites

i obviously use a logger every single day of my life at work. but clearly it may be overkill for a minecraft mod... just saying. maybe im wrong and your mod is reaaaaaally big and you actualy need it. but i consider that im doing a big one and i dont need a logger

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

i obviously use a logger every single day of my life at work. but clearly it may be overkill for a minecraft mod... just saying. maybe im wrong and your mod is reaaaaaally big and you actualy need it. but i consider that im doing a big one and i dont need a logger

 

I don't NEED a logger but I really like the advantages of it. I first did not like it either. But now I really enjoy seeing instantly how important a message in the console is.

(And I guess a mod of 10k lines is no longer considered a small mod, is it?  ;))

Link to comment
Share on other sites

yeah i understand, but this is a java issue not a forge issue, you should be able to find this in google easily

 

(btw mine has 18-19k :P, but yeah id consider 10k a big mod xD)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Well after doing some sirious research I found out that the following code should work:

 

logger.setLevel(myLevel);

for(Handler handler : loger.getHandlers()) {
  handler.setLevel(myLevel);
}

 

It does not and that for a specific reason:

 

In the class where the main logger is set up there is this line:

ConsoleLogThread.wrappedHandler.setLevel(Level.parse(System.getProperty("fml.log.level","INFO")));

 

Which basically sets the logging level for the console to Level.INFO in a way that makes it (almost (not sure if possible or not)) impossible to overwrite with your own logger. "ConsoleLogThread" is a private class in this class so I cannot access it.

 

So how could I still change this level for my logger? (The class the code is found: cpw.mods.fml.relauncher.FMLRelaunchLog)

 

I hope you understand my problem!

Link to comment
Share on other sites

So why can't you just monitor the Forge-client log (or server log)? There are ways to tee that to a window, depending on what OS you are using. (In linux it would be "tail -f <filename>", of course)  Why does it have to be the console log?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm developing a dimension, but it's kinda resource intensive so some times during player teleporting it lags behind making the player phase down into the void, so im trying to implement some kind of pregeneration to force the game loading a small set of chunks in the are the player will teleport to. Some of the things i've tried like using ServerLevel and ServerChunkCache methods like getChunk() dont actually trigger chunk generation if the chunk isn't already on persistent storage (already generated) or placing tickets, but that doesn't work either. Ideally i should be able to check when the task has ended too. I've peeked around some pregen engines, but they're too complex for my current understanding of the system of which I have just a basic understanding (how ServerLevel ,ServerChunkCache  and ChunkMap work) of. Any tips or other classes I should be looking into to understand how to do this correctly?
    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
    • When I came across the 'Exit Code: I got a 1 error in my Minecraft mods, so I decided to figure out what was wrong. First, I took a look at the logs. In the mods folder (usually where you'd find logs or crash reports), I found the latest.log file or the corresponding crash report. I read it through carefully, looking for any lines with errors or warnings. Then I checked the Minecraft Forge support site, where you can often find info on what causes errors and how to fix them. I then disabled half of my mods and tried running the game. If the error disappeared, it meant that the problem was with the disabled mod. I repeated this several times to find the problem mod.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.