Jump to content

Recommended Posts

Posted

Hey guys

 

So I'm slowly but surly making my mod by following every kind of tutorial I can find, however in many example codes I find I see something called a logger mixed into the code. After doing some research I found out that this part of the log4j api which basically responsible for printing all the text in console when you boot up an instance of forge (INFO, ERROR, ext...) which is something I find very useful and probably better than using println()

 

however despite all these examples that have loggers placed in them I cant seem to find out how modders are actually using them.

 

I followed McJty's Basic Mod - 1.9 tutorial and added logger = event.getModLog() into my preInit and included org.apache.logging.log4j.Logger but now I dont know how to use it, or if I even need to use it

 

does anyone have any experience with loggers or is this something I shouldn't worry about? if this is something worth using are there any tutorials regarding it? (didn't seem to find any here)

Posted

You can use Logger#info, Logger#debug, Logger#warn, etc. quite easy. So what is your problem? Referencing?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

There's also Logger#log(Level,Message)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You can use Logger#info, Logger#debug, Logger#warn, etc. quite easy. So what is your problem? Referencing?

 

well what my problem is in how to actually use it, for example in my CommonProxy file I have within the preInit "ModBlocks.init();" and "ModItems.init();" which loads all my stuff, I would l to print to console using the logger "Loading *my mod's* blocks" then "Done Loading *my mod's* blocks" that way if any errors happen with loading all I have to find are those two blocks of text

 

to do this would I just have to type

Logger#info("Loading " + Reference.MOD_ID + "'s Blocks")

Posted

No, java won't understand something like '#' there.

You should get the logger and call the method of it named 'info'. (It was what I meant by 'Logger#info)

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

No, java won't understand something like '#' there.

You should get the logger and call the method of it named 'info'. (It was what I meant by 'Logger#info)

 

welp It seems I need to go back to Java class because the solution to my problem was rediculasly easy to fix, I read that I had to use logger.info("string") for it to work but every time I tryed to use it on a file that wasn't the mod file I couldn't get it to work

 

turns out I forgot that I dont have to type logger.info(), I have to type *mymodfile*.logger.info(). I actually feel a bit of shame for not realizing that sooner

 

Thanks anyway you guys

Posted

"Logger#info" means you need an object of Type "Logger" and you need to invoke the method "info" on it.  In your other files you tried doing just "logger.info(string)" but that didn't work because you didn't have an object of Type Logger in that scope.

 

So yeah, this was one of the more painful things I've read on this forum in a while.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.