Skip to content
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

Logging Managment #135

Closed
inbalzukerman opened this issue Mar 29, 2017 · 9 comments
Closed

Logging Managment #135

inbalzukerman opened this issue Mar 29, 2017 · 9 comments
Assignees

Comments

@inbalzukerman
Copy link
Collaborator

Research upon a logging system for our project.
As discussed in our meeting, try to research first the classes Fault and Monitor from the Spartanizer project.

@RonGatenio
Copy link
Contributor

started working on a wiki page for Log4j

@inbalzukerman
Copy link
Collaborator Author

@RonGatenio, can this issue be closed?

This was referenced Apr 3, 2017
@RonGatenio
Copy link
Contributor

not yet... I need read about slf4j first
@inbalzukerman

@inbalzukerman
Copy link
Collaborator Author

Let us know so we could start working on #146, #147, #148 😄

@RonGatenio
Copy link
Contributor

@inbalzukerman
You can start working on those issues.
If we will change from Log4j to Slf4j, the changes to the code will be minor, because their syntax is identical.

@inbalzukerman
Copy link
Collaborator Author

Yay! Thank you 👍

@RonGatenio
Copy link
Contributor

RonGatenio commented Apr 7, 2017

I changed the logger to slf4j (I'll explain why later). For now, this is the new syntax:

import org.slf4j.LoggerFactory;
import org.slf4j.Logger;

public class MyClass {
    private static Logger log = LoggerFactory.getLogger(MyClass.class);
}

Note that log4j is still accessible (slf4j uses log4j... again, I'll explain this later...). So avoid using it!

Also, there is no longer a fatal alert level 😢


The old syntax (for a remainder):
import org.apache.log4j.Logger;

public class MyClass {
    private static Logger log = Logger.getLogger(MyClass.class);
}

@inbalzukerman @EliaTraore @ylevv @roy-shchory @alexvitho

@RonGatenio
Copy link
Contributor

RonGatenio commented Apr 8, 2017

Something nice about the logger...
You can log a string and an exception in the following way:

public void myFunc() {
   try {
      //...
   } catch (Exception e) {
      log.error("Big error, very bad!", e);
   }
}

This will log the string and the stack trace:

2017-04-08 03:40:02 ERROR [JavaFX Application Thread] api.SmartHouseApplication#myFunc (SmartHouseApplication.java:54) - Big error, very bad! 
java.lang.IllegalStateException: Location is not set.
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
	//...
	at java.lang.Thread.run(Unknown Source)

#146 #147 #148

@RonGatenio
Copy link
Contributor

Another thing, try to avoid System.out.println("...") in the code...
Use log.debug("...") instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants