Jump to content

Recommended Posts

Posted

Greetings, I downloaded and installed the latest 1.7.2 source and when I tried to setup logging like the old tutorials examples Eclipse indicated that there was problems with the following statements.

 

public static Logger logger;
logger = Logger.getLogger(MODID);
logger.setParent(FMLLog.getLogger());

 

When I investigated the FML source I discovered that FMLLog no longer imports

 

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

 

 

but instead uses

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;

 

If i import log4j I get an error with "logger = Logger.getLogger(MODID);"

if I import the old java.util.logging i get errors with "logger.setParent(FMLLog.getLogger());"

 

So how do I properly use Logging with 1.7.2 mods?

 

 

Thanks in advanced

 

GuardStar

 

GuardStar

Posted

I use my common proxy class.

 

import cpw.mods.fml.common.FMLLog;
import org.apache.logging.log4j.Logger;

private static final Logger logger = FMLLog.getLogger();

.
.
.
public void print(String s)
{
logger.info(s);
}

Posted

I'm using this, which seems to work:

 

public static org.apache.logging.log4j.Logger logger;

 

@EventHandler

public void preInit(FMLPreInitializationEvent event){

    logger = event.getModLog();

 

    logger.info("Something");

}

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.

Announcements



×
×
  • Create New...

Important Information

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